$cs.Sys_KillProcess
Description
Section titled “Description”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.
Syntax
Section titled “Syntax”$cs.Sys_KillProcess(string processname)
Parameters
Section titled “Parameters”processname (String)
Section titled “processname (String)”Name (or substring of the name) of the process(es) to kill. The .exe extension is optional.
Return value
Section titled “Return value”None.
Example
Section titled “Example”Force-close an application before an in-place upgrade so its files aren’t locked:
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++):
$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:
foreach ($processName in @("AppMain", "AppTray", "AppUpdater")){ if ($cs.Sys_ExistProcess($processName)) { $cs.Job_WriteLog("Killing leftover process $processName") $cs.Sys_KillProcess($processName) }}Related functions
Section titled “Related functions”$cs.Sys_ExistProcess $cs.Sys_WaitForProcess $cs.Sys_WaitForProcessToExist