# $cs.Sys_ExistProcess

> Checks whether a process with the given name is currently running. The file extension is stripped automatically, so "notepad" and "notepad.exe" both work.

Source: https://docs.capaone.com/capainstaller/powerpacks/cs-sys-existprocess/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

### Description

Checks whether a process with the given name is currently running. The file extension is stripped automatically, so `"notepad"` and `"notepad.exe"` both work. Note: if an internal error occurs while checking, the function returns `true` rather than `false` or throwing — so a "no" result is reliable, but a "yes" should not be treated as an absolute guarantee in every edge case.

### Syntax

$cs.Sys_ExistProcess(string processname)

### Parameters

#### processname (String)

Name of the process to check for. The `.exe` extension is optional.

### Return value

Boolean. `$true` if the process is currently running, otherwise `$false`.

### Example

**PowerShell**

Check whether the target application is running before killing it and continuing an in-place upgrade:

```powershell
if ($cs.Sys_ExistProcess("Firefox.exe"))
{
  $cs.Job_WriteLog("Firefox is running, killing it before continuing")
  $cs.Sys_KillProcess("Firefox")
}
```

Skip a disruptive upgrade entirely if the application is currently in use, instead of forcing it closed:

```powershell
if ($cs.Sys_ExistProcess("Outlook"))
{
  $cs.Job_WriteLog("Outlook is currently running, postponing upgrade to avoid data loss")
  throw "Outlook is running, aborting install"
}
else
{
  $cs.Job_WriteLog("Outlook is not running, proceeding with upgrade")
}
```

Warn before removing an application's files during uninstall if it still appears to be running:

```powershell
if ($cs.Sys_ExistProcess("MyLegacyApp"))
{
  $cs.Job_WriteLog("MyLegacyApp is still running, files may be locked during removal")
}
```

### Related functions

[$cs.Sys_KillProcess](/capainstaller/powerpacks/cs-sys-killprocess/) [$cs.Sys_WaitForProcess](/capainstaller/powerpacks/cs-sys-waitforprocess/) [$cs.Sys_WaitForProcessToExist](/capainstaller/powerpacks/cs-sys-waitforprocesstoexist/)
