TerminateApp( winname/appname, name-type, flags )
(s) winname/appname specifies a window name or application name, depending on the value of "name-type".
(i) name-type number that specifies what type of value was passed in "winname/appname". See below.
(i) flags see below.
(i) @TRUE on success and @FALSE on failure.
"winname/appname" specifies a window name or application name, depending on the value of "name-type"
name-type |
winname/appname |
0 |
full or partial windowname of a WinBatch program window |
2 |
full or partial windowname of a Windows program window |
3 |
application file name of a Windows program |
"flags" can be set to 0, or can specify one or more of the following values combined with the bitwise OR ('|') operator:
Value |
Meaning |
0 |
Default |
1 |
"current-session-only" flag (valid only if "name-type" == 3). If this flag is specified, and the script is running in a Terminal Services environment, then the specified application will only match if it is running in the same session as the script. Otherwise, the specified application will match regardless of what session it is running in. |
This function lets you terminate an application abruptly. Normally, you should use WinClose to close an application gracefully, but sometimes that may not be possible. Using this function is a drastic, last-resort method of terminating an app.
Note: You will not receive any warning from the operating system before the application is closed, even if it contains unsaved work. Also, this function may leave the system in an unstable state. Use this function carefully.
Windows Vista/2008 and newer: This function may require an Administrator level account, because it relies on performance monitoring.
appname = "notepad.exe" Run(appname, "") Message( appname, "Running") TerminateApp(appname,3, 0) Message( appname, "Terminated")