ProcessClose()

Auto Hotkey

ProcessClose

Closes a process.

OutputVar := ProcessClose(PID-or-Name)
Command  Example: ProcessClose "Notepad.exe"
Function Example: PID := ProcessClose("Notepad.exe")
OutputVar

The name of the variable in which to store the PID of closed process or 0 / false otherwise (there was no matching process or there was a problem terminating it).

PID-or-Name

This parameter can be either a number (the PID) or a process name as described below. It can also be left blank to get PID of the script itself.

PID: The Process ID, which is a number that uniquely identifies one specific process (this number is valid only during the lifetime of that process). The PID of a newly launched process can be determined via the Run command. Similarly, the PID of a window can be determined with WinGet.

Name: The name of a process is usually the same as its executable (without path), e.g. notepad.exe or winword.exe. Since a name might match multiple running processes, only the first process will be reported. The name is not case sensitive.

Remarks

Since the process will be abruptly terminated -- possibly interrupting its work at a critical point or resulting in the loss of unsaved data in its windows (if it has any) -- this method should be used only if a process cannot be closed by using WinClose on one of its windows.

Related

ProcessExist, ProcessSetPriority, ProcessWait , ProcessWaitClose, Run, WinGet, WinClose, WinKill, WinWait, WinWaitClose, WinExist

Examples

ProcessClose, OurPID, Notepad.exe