ShellWait
System function.
The ShellWait function executes a program (.exe, .com, .bat, .doc, .txt, ...) and waits for its termination before running next statement.
Usage
The main usage of the ShellWait function is to start a Dos application, a batch file or a console application and to wait until the application has finished before moving to next step. Using ShellWait, you can launch a Dos command such as xcopy and next step will be executed only when the filecopy has finished.
Syntax
ShellWait (<command$>,<mode>,<timeout>[,<processExitCode>[,output$]])
or
ret=ShellWait (<command$>,<mode>,<timeout>[,<processExitcode>[,output$]])Parameters
<command$>: string, name of the program to be run with any parameters (parameters must be strings).
<mode> speficies window size during exeuction: 1 for normal execution, 2 for minimized execution, 3 for maximized execution, 4 for hidden (character-mode applications), 5 for hidden and when <timeout> is elapsed, process is killed ( in mode 4, process is not killed).
If after <timeout> seconds, the program launched by <command$> is not terminated, return code ret is set to -1. If <timeout> is set to 0, there is no limitation for execution duration.
<ProcessExitCode>: optional integer variable; it gives the return code of the program launched by <command$> at its termination. If <timeout> has been reached before program termination, <ProcessExitCode> is set to -1.
output$ is a string containing the two outputs stdout and stderr (only if <mode> is set to 4 or 5). It's the text displayed during character-based or Dos programs execution. If the program does not output anything to the console, this last parameter must not be present.
Return value
Ret, numeric return code. When the program has been launched successfully, the function returns 0, otherwise use this return code for Error Handling.
See also
Examples
shellwait("xcopy c:\*.* d:\save /S",1,1000)
msgbox("Dos command end")
Dos box is opened, WinTask script execution suspends and the following message box is displayed either when job in Dos box is finished, either when the specified timeout of 1000 seconds has been reached.