Function Reference

RunWait

Runs an external program and pauses script execution until the program finishes.

RunWait ( "filename" [, "workingdir" [, flag]] )

 

Parameters

filename The name of the executable (EXE, BAT, COM, PIF) to run.
workingdir [optional] The working directory.
flag [optional] The "show" flag of the executed program:
  @SW_HIDE = Hidden window (or Default keyword)
  @SW_MINIMIZE = Minimized window
  @SW_MAXIMIZE = Maximized window

 

Return Value

Success: Returns the exit code of the program that was run.
Failure: Returns 0 and sets @error to non-zero.

 

Remarks

To run DOS commands, try RunWait(@ComSpec & " /c " & "commandName") ; don't forget " " before "/c"

After running the requested program the script pauses until the program terminates. To run a program and then immediately continue script execution use the Run function instead.

Some programs will appear to return immediately even though they are still running; these programs spawn another process - you may be able to use the ProcessWaitClose function to handle these cases.

 

Related

ProcessWait, ProcessWaitClose, Run, ShellExecute, ShellExecuteWait, RunAs, RunAsWait

 

Example


$val = RunWait("Notepad.exe", @WindowsDir, @SW_MAXIMIZE)
; script waits until Notepad closes
MsgBox(0, "Program returned with exit code:", $val)