Runs an external program.
Run ( "program" [, "workingdir" [, show_flag [, opt_flag]]] )
Paths with spaces need to be enclosed in quotation marks.
To run DOS (console) commands, try Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE) ; don't forget " " before "/c"
After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the RunWait() function instead.
Providing the Standard I/O parameter with the proper values permits interaction with the child process through the StderrRead(), StdinWrite() and StdoutRead() functions. Combine the flag values (or use $STDERR_CHILD, $STDIN_CHILD & $STDOUT_CHILD) to manage more than one stream.
In order for the streams to close, the following conditions must be met:
1) The child process has closed its end of the stream (this happens when the child closes).
2) AutoIt must read any captured streams until there is no more data.
3) If STDIN is provided for the child, StdinWrite() must be called to close the stream. Once all streams are detected as no longer needed, all internal resources will automatically be freed.
StdioClose() can be used to force the STDIO streams closed.
ConsoleRead, ProcessClose, RunAs, RunAsWait, RunWait, ShellExecute, ShellExecuteWait, StderrRead, StdinWrite, StdioClose, StdoutRead
Example()
Func Example()
; Run Notepad with the window maximized.
Local $iPID= Run ("notepad.exe","",@SW_SHOWMAXIMIZED )
; Wait 10 seconds for the Notepad window to appear.
WinWait ("[CLASS:Notepad]","",10)
; Wait for 2 seconds.
Sleep (2000)
; Close the Notepad process using the PID returned by Run.
ProcessClose ($iPID)
EndFunc ;==>Example