KillAppChildren – System Function






KillAppChildren Function


Usage

The KillAppChildren function kills the specified application and its associated children. This function is not available in WinTask Lite.

Used to force an application (a program file or EXE) to close, along with its child processes.

Syntax

KillAppChildren(<exe_name>, 0|1 [, <user_name>])
or
ret = KillAppChildren(<exe_name>, 0|1 [, <user_name>])

Parameters

  • <exe_name>: string, name of the application to kill along with its children. The name is not case sensitive and the extension is not compulsory (e.g., Notepad.exe, Notepad, or NOTEPAD are valid).
  • 0|1: integer, if 1, the application and its children are killed immediately. If 0, a confirmation dialog is displayed if the application cannot be killed after 60 seconds.
  • <user_name>: string, optional. If specified, kills only the instances of the specified application started by the user <user_name>.

Return Value

Ret, numeric return code. Possible values:

  • 0 if the application and its children have been killed successfully.
  • 1 if the application and its children have been killed after user confirmation.
  • Negative values if the application could not be killed (e.g., -3 if the kill was cancelled by the user, -4 if access was denied, -1 for any other reason).

See Also

  • KillApp

Example

'The script below launches Notepad, types some text, and exits. A dialog box is displayed asking if the document has to be saved.
'As KillAppChildren is used with the 1 flag, the application Notepad and its children are killed immediately.
Shell("notepad", 1)
UseWindow("NOTEPAD.EXE|Edit||1", 1)
SendKeys("Hello")
'Exit Notepad
UseWindow("NOTEPAD.EXE|Notepad|", 1)
SendKeys(">")
'Kill Notepad and its children immediately
KillAppChildren("notepad", 1)