Skip to content

$cs.Sys_KillProcess

Kills every running process whose name contains processname as a substring (case-insensitive), not just an exact match — for example "chrome" would also match and kill a process named "chromehelper". Pick a name specific enough to avoid collateral kills. Waits for each killed process to fully exit before returning.

$cs.Sys_KillProcess(string processname)

Name (or substring of the name) of the process(es) to kill. The .exe extension is optional.

None.

Force-close an application before an in-place upgrade so its files aren’t locked:

Terminal window
if ($cs.Sys_ExistProcess("Firefox.exe"))
{
$cs.Job_WriteLog("Killing Firefox before continuing install")
$cs.Sys_KillProcess("Firefox")
}

Kill a specific helper process by its full name rather than a short substring, to avoid accidentally matching unrelated processes (for example "note" would also match OneNote or notepad++):

Terminal window
$cs.Job_WriteLog("Stopping the vendor update helper before uninstalling the application")
$cs.Sys_KillProcess("VendorUpdateHelper.exe")

Clean up a known set of leftover processes during uninstall:

Terminal window
foreach ($processName in @("AppMain", "AppTray", "AppUpdater"))
{
if ($cs.Sys_ExistProcess($processName))
{
$cs.Job_WriteLog("Killing leftover process $processName")
$cs.Sys_KillProcess($processName)
}
}

$cs.Sys_ExistProcess $cs.Sys_WaitForProcess $cs.Sys_WaitForProcessToExist