exec

Runs an application.

exec <command line> [<show> [<wait> [<current directory>]]]

Remarks

Runs an application specified by <command line>.

Parameters

string <show> (optional default="show")
The following are display style:
integer <wait> (optional default=0) (version 4.63 or later)
If it is 1, macro waits to finish the launched application. The exit code of the application stores the `result' system variable.
If it is not 1, macro launches the application and control is returned to macro.
string <current directory> (optional default="") (version 4.78 or later)
A current directory can be specified.

Return Value

System variable <result>
version 4.63 to 4.102
If integer value <wait> is 1, the exit code of the application is stored.
version 4.103 or later
If integer value <wait> is 1
Value Meaning
-1 Failed to execute the application.
not -1 The exit code of the application

If integer value <wait> is not 1
Value Meaning
-1 Failed to execute the application.
0 Succeeded to execute the application.

Example

; Run "Notepad".
exec 'notepad readme.txt'

; Run "Notepad" and maximize the application.
exec 'notepad readme.txt' 'maximize'

; Run "Notepad" with the current directory.
exec 'notepad readme.txt' 'show' 0 'c:\usr'
; Launch a batch file.
tmp='cmd /c c:\upload.bat '
strconcat tmp username1 
strconcat tmp ' '
strconcat tmp userpass1 
strconcat tmp ' '
strconcat tmp address
messagebox tmp 'exec'
exec tmp
; Make a directory.
getenv "USERPROFILE" userprof
getdate logdir "log-%Y%m%d"
sprintf2 cmd 'cmd /c mkdir "%s\My Documents\%s"' userprof logdir
exec cmd "HIDE"

Note

When the macro script is executed on the 64bit Windows, an WOW64's application will not work well.

The 32bit application can launch because the ttpmacro.exe is the 32bit program. An application will launch the 64bit program again when the 32bit program is executed on the 64bit operating system.
If the <wait> is specified, the exec macro will continue to next step because the 32bit program launched by the macro script terminates soon.

Please use the sysnative alias and launches the native application in the system directory to resolve this problem.

; fail
exec 'mstsc /v 192.0.2.0 /w 1024 /h 768 /admin' 'show' 1

; succeed
exec 'C:\windows\sysnative\mstsc /v 192.0.2.0 /w 1024 /h 768 /admin' 'show' 1