Jump to content

Run command in windows xp


mcgill
 Share

Recommended Posts

Tried with Run(@WindowsDir & "\explorer.exe") , application still failing.

$ret = _GUICtrlListViewGetItemText ($listview1, -1, 0)

; Set the RunAs parameters to use local adminstrator account

;$USERNAME = "***********"

;$PASSWORD = "**********"

$DOMAIN = @LogonDomain ;"domain.com"

$RUN = 0 ; run indicator

; retrieve the cycle from commandline

If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1]

If $RUN = 0 Then

RunAsSet($username, $DOMAIN, $password)

;Run(@WindowsDir & "\explorer.exe") - line fails here on winxp service pack 2

;run("explorer") - also this line of code does too, both examples don't work

WinWaitActive("My Documents")

Send("!d")

$x = StringFormat("%s", $ret)

;msgbox(0,"", $x)

Send($x & "{ENTER}")

RunAsSet()

endif

Link to comment
Share on other sites

  • Developers

Tried with Run(@WindowsDir & "\explorer.exe") , application still failing.

$ret = _GUICtrlListViewGetItemText ($listview1, -1, 0)

; Set the RunAs parameters to use local adminstrator account

;$USERNAME = "***********"

;$PASSWORD = "**********"

$DOMAIN = @LogonDomain ;"domain.com"

$RUN = 0 ; run indicator

; retrieve the cycle from commandline

If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1]

If $RUN = 0 Then

RunAsSet($username, $DOMAIN, $password)

;Run(@WindowsDir & "\explorer.exe") - line fails here on winxp service pack 2

;run("explorer") - also this line of code does too, both examples don't work

WinWaitActive("My Documents")

Send("!d")

$x = StringFormat("%s", $ret)

;msgbox(0,"", $x)

Send($x & "{ENTER}")

RunAsSet()

endif

Where are you running this script from ? (server?)

Try added the Workdir on the Run command.. something like @tempdir should do...

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

It's the RunAsSet that's causing your trouble, there are measures to prevent EXPLORER.EXE from running with different credentails in Win XP.

I've worked around this in the past by calling the Internet Explorer EXE instead. I typically do this by hand, I don't know if IE would accept a starting address of "My Documents" on the command-line, but you could try...

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

But, why are you running explorer hidden? Can a hidden window be active?

They aren't running explorer hidden, the command window that they are calling explorer from is hidden

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

http://blogs.msdn.com/aaron_margosis/archi.../07/175488.aspx

Option 2. Set the flag that allows explorer.exe to work with RunAs

Its actually very simple. The trick is to set the folder option to Launch folder windows in a separate process. This is a per-user option, off by default, that needs to be set for the target user account. That is, if you want to use RunAs to start explorer.exe as MyAdminAccount, then MyAdminAccount needs to have the separate process option set. Once this flag has been set, you can start explorer.exe with RunAs, or from your admin cmd shell.

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

I have a similar problem. I'm trying to download the latest java runtime environment and then run it silently. I already have an autoit script to run it silently and I just want to dl it first. I'm just having trouble hitting the target url. I went the @ComSpec route prior but couldn't seem to get the syntax to hit the iexplore.exe and the url at the same time. I got it to work with send comands but I'm wanting to do this more reliably than that.

Here's what I've got now:

$ie = "C:\Program Files\Internet Explorer\iexplore.exe"

$jre = "http://jdl.sun.com/webapps/download/AutoDL?BundleId=10433" ;offline win install

If FileExists(@ProgramFilesDir & "\Java\jre1.5.0_06") Then

MsgBox ( 0, "Java", "JRE 1.5.0.06 already installed.", 5 )

Exit

Else

Run($ie & $jre)

EndIf

Exit

My last @ComSpec line was:

Run(@ComSpec & " /c " & "C:\Program Files\Internet Explorer\iexplore.exe" 'http://jdl.sun.com/webapps/download/AutoDL?BundleId=10433', "")

I took out the hide to keep my sanity.

Any help/suggestions would be greatly appreciated.

Link to comment
Share on other sites

@acastle :

1. You're trying to run "iexplore" with a link. Try adding a space between it and the link, or else

it will try to run file with this strange name : "iexplore.exehttp://jdl.sun.com/webapps/downl..."

2. You're sure that "Java\jre1.5.0_06" doesn't have an extension ? Like ".exe" ?

3. Back to your download-thingie again. Why don't you just use INetGet() ?

Edit : 4. You're using Run() to start @ComSpec which again starts "iexplore.exe".

That's not needed as Run() is very able to run it "iexplore.exe" directly.

Edited by Helge
Link to comment
Share on other sites

@Helge :

"Java\jre1.5.0_06" is a folder and in it is the \bin\java.exe. Each version of the jre installs to a seperate folder inside the main Java folder.

I overlooked the InetGet() and will try that out. I'm sure it will work just fine.

Thanks,

Link to comment
Share on other sites

Alright so RUNAS does not work with WIN XP sp2 with explorer but can I use it with iexplore.exe? I changed my code with this and works fine with win 2000, but when running on win xp it won't open iexplore.exe even though it is pointing to the correct path, any ideas?

$ret = _GUICtrlListViewGetItemText ($listview1, -1, 0)

; Set the RunAs parameters to use local adminstrator account

$USERNAME = "*********"

$PASSWORD = "********"

$DOMAIN = @LogonDomain ;"domain.com"

$RUN = 0 ; run indicator

; retrieve the cycle from commandline

If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1]

If $RUN = 0 Then

RunAsSet($username, $DOMAIN, $password)

Run("C:\Program Files\Internet Explorer\iexplore.exe")

WinWaitActive("Ceridian's Intranet")

Send("!d")

$x = StringFormat("%s", $ret)

Send($x & "{ENTER}")

RunAsSet()

endif

Link to comment
Share on other sites

Small change to try.

$ret = _GUICtrlListViewGetItemText ($listview1, -1, 0)
; Set the RunAs parameters to use local adminstrator account 
$USERNAME = "*********" 
$PASSWORD = "********" 
$DOMAIN = @LogonDomain ;"domain.com" 
$RUN = 0 ; run indicator 
; retrieve the cycle from commandline 
If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1] 
If $RUN = 0 Then 
    RunAsSet($username, $DOMAIN, $password)
    $workingdir = @WorkingDir
    If FileChangeDir("C:\Program Files\Internet Explorer") Then
        Run("iexplore.exe")
        WinWaitActive("Ceridian's Intranet") 
        Send("!d") 
        $x = StringFormat("%s", $ret)
        Send($x & "{ENTER}")
        FileChangeDir($workingdir)
    Else
        MsgBox(0, 'Debug', 'Could not change directory'); debug
    EndIf   
    RunAsSet() 
endif

An option to troubleshoot could be to run @ComSpec from this script and see what working dir your in and whether "C:\Program Files\Internet Explorer..." is visible by command CD to it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...