Core Function RunWait
Line 1: | Line 1: | ||
<pre> | <pre> | ||
− | RunWait( <file>, <arguments>, <workdir>, <flag>, <show options> ) | + | RunWait( <file>, <timeout>, <arguments>, <workdir>, <flag>, <show options> ) |
</pre> | </pre> | ||
Line 12: | Line 12: | ||
The name of the executable (EXE, BAT, COM, or PIF) to run. | The name of the executable (EXE, BAT, COM, or PIF) to run. | ||
+ | |||
+ | ==== timeout ==== | ||
+ | |||
+ | Optional; Amount of seconds to wait for process to terminate. | ||
+ | |||
+ | Default -1 which means wait forever. | ||
==== arguments ==== | ==== arguments ==== |
Revision as of 17:42, 1 December 2011
RunWait( <file>, <timeout>, <arguments>, <workdir>, <flag>, <show options> )
Contents |
Description
Runs an external program and waits until the program finishes.
Parameters
file
The name of the executable (EXE, BAT, COM, or PIF) to run.
timeout
Optional; Amount of seconds to wait for process to terminate.
Default -1 which means wait forever.
arguments
Optional; The arguments to use.
workdir
Optional; The working directory.
flag
Optional; The "show" flag of the executed program:
@SW_HIDE = Hidden window @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window
Default runs the program normally.
show options
Optional; Options how to executed program will run:
0 = Run within the current process so that anything printed to console by the run program appears directly on ours. 1 = Run the program within its own window and dont share our console.
Default 0.
Return Value
Success: The PID of the process that was launched.
Failure: 0.
Remarks
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.
Example
$val = RunWait('Notepad.exe', 'C:\WINDOWS', @SW_SHOWNORMAL); // script waits until Notepad closes MsgBox("Program returned with exit code: $val");