Method process.terminate(+ 1 overload)
Overload
Terminates (ends) the specified process.
public static bool terminate(int processId, int exitCode = 0)
Parameters
Returns
Remarks
Uses API WTSTerminateProcess or TerminateProcess. They are async; usually the process ends after 2 - 200 ms, depending on program etc.
Does not try to end process "softly" (close main window). Unsaved data will be lost.
Alternatives: run taskkill.exe
or pskill.exe
(download). See run.console. More info on the internet.
Examples
Restart the shell process (explorer).
process.terminate(wnd.getwnd.shellWindow.ProcessId, 1);
if (!dialog.showYesNo("Restart explorer?")) return;
run.it(folders.Windows + @"explorer.exe", flags: RFlags.InheritAdmin);
Overload(top)
Terminates (ends) all processes of the specified program or programs.
public static int terminate(string processName, bool allSessions = false, int exitCode = 0)
Parameters
processName (string)
Process executable file name (like |
allSessions (bool)
Processes of any user session. If |
exitCode (int)
Process exit code. |
Returns
int
The number of successfully terminated processes. |
Exceptions
ArgumentException
|