Jump to content

Run command in windows xp


mcgill
 Share

Recommended Posts

I'd be very explicit on setting the working directory. You need to make sure it's set to a path the RunAs user can access. For example, if you are running the script from your Desktop, the RunAs user may not have read/write rights to your Desktop but that is what the working directory will be set to.

So in other words, don't use @WorkingDir and don't leave the working directory parameter to Run()/RunWait() empty. Explicitly set it to C:\ or the path of the executable, somewhere you know all users have access to.

Edit: Couple other things.

I see that's kind of what MHz was getting at. It shouldn't be necessary to use FileChangeDir(), though. You definitely must make sure the working directory paramter is set to something the alternate user can access, though.

The second thing is Explorer can be started with alternate credentials - I've done it many times. I would say that what lod3n posted is correct. I have Explorer configured as described and I've always been able to get Explorer to launch under alternate credentials either using AutoIt with RunAsSet() or runas from the command line.

Edited by Valik
Link to comment
Share on other sites

  • 6 months later...

Hey Guys, I am trying somthing similar in trying to connect to a remote machine's C Drive:

Has anyone been able to get a resolution on this, or is it a WinXpSp2 "feature?"

Code being used is as follows:

$Adminform = GUICreate("Logon", 251, 145, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS))
$AdminOkbtn = GUICtrlCreateButton("&OK", 86, 112, 75, 25, 0)
$AdminCancelbtn = GUICtrlCreateButton("&Cancel", 167, 112, 75, 25, 0)
$Label1 = GUICtrlCreateLabel("Password:", 8, 52, 53, 17)
$Label1 = GUICtrlCreateLabel("Administrator:", 8, 18, 67, 17)
$ADMININPUT = GUICtrlCreateInput("", 88, 16, 153, 21)
GUICtrlSetState(-1, $GUI_FOCUS)
$ADMINPSWDINPUT = GUICtrlCreateInput("", 88, 48, 153, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
$Label2 = GUICtrlCreateLabel("Domain", 8, 82, 40, 17)
$DOMAININPUT = GUICtrlCreateInput("", 88, 80, 153, 21, $ES_UPPERCASE)
GUISetState(@SW_SHOW)

Global $sADMININPUTrslt =GUICtrlRead($ADMININPUT)
Global $sPswdinputrslt = GUICtrlRead($ADMINPSWDINPUT)
Global $sDomaininputrslt = GUICtrlRead($DOMAININPUT)


Func _ConnectoCdrv()    


    If $sSpecifyMachineName = "" Then
        MsgBox(16, "Error!", "Machine name is missing.")
    Else

;Ping machine to see if it contactable
        $Pingrslt = Ping($sSpecifyMachineName, 300)
        
        $Errmsg = @error
        
        Select
            
            Case $Errmsg = 0                

                RunAsSet($sADMININPUTrslt, $sDomaininputrslt, $sPswdinputrslt, 2)
                $Process = Run('Explorer \\' & $sSpecifyMachineName & '\C$', @WindowsDir, @SW_SHOW)
    
            Case $Errmsg = 1
                MsgBox(16, "Error!", $sSpecifyMachineName & " Host is offline")
                Return
            Case $Errmsg = 2
                MsgBox(16, "Error!", $sSpecifyMachineName & " Host is unreachable")
                Return
            Case $Errmsg = 3
                MsgBox(16, "Error!", $sSpecifyMachineName & " Host has a bad destination address")
        EndSelect   

    EndIf


EndFunc
Link to comment
Share on other sites

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...