Runs an external program under the context of a different user and pauses script execution until the program finishes.
RunAsWait ( "username", "domain", "password", logon_flag, "program" [, "workingdir" [, show_flag [, opt_flag]]] )
|username||The username to log on with.|
|domain||The domain to authenticate against.|
|password||The password for the user.|
|logon_flag||0 - Interactive logon with no profile.
1 - Interactive logon with profile.
2 - Network credentials only.
4 - Inherit the calling process's environment instead of the user's environment.
|program||The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks).|
|workingdir||[optional] The working directory. If not specified, then the value of @SystemDir will be used. This is not the path to the program.|
|show_flag|| [optional] The "show" flag of the executed program:
@SW_HIDE = Hidden window (or Default keyword)
@SW_MINIMIZE = Minimized window
@SW_MAXIMIZE = Maximized window
|opt_flag|| [optional] Controls various options related to how the parent and child process interact.
0x10000 ($RUN_CREATE_NEW_CONSOLE) = The child console process should be created with its own window instead of using the parent's window. This flag is only useful when the parent is compiled as a Console application.
|Success:||the exit code of the program that was run.|
|Failure:||sets the @error flag to non-zero.|
#include <MsgBoxConstants.au3> Example() Func Example() ; Change the username and password to the appropriate values for your system. Local $sUserName = "Username" Local $sPassword = "Password" ; Run Notepad and wait for the Notepad process to close. Notepad is run under the user previously specified. Local $iReturn = RunAsWait($sUserName, @ComputerName, $sPassword, 0, "notepad.exe") ; Display the return code of the Notepad process. MsgBox($MB_SYSTEMMODAL, "", "The return code from Notepad was: " & $iReturn) EndFunc ;==>Example