Wednesday, February 26, 2014

How to check a process or program is running via powershell script

Powershell script to check if a program is running or not

$Prog = "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
$Running = Get-Process firefox -ErrorAction SilentlyContinue
$Start = {([wmiclass]"win32_process").Create($Prog)}
if($Running -eq $null) # evaluating if the program is running
{& $Start} # the process is created on this line

3 comments:

Unknown said...

The actual time and effort taken to create this wonderful article were really great and would like to watch this blog regularly to get more useful stuff thanks much for sharing here...
Best Online Software Training Institute | Unix Linux Online Training

Research Proposal Help UK said...

You can use the Get-Process cmdlet to check if a process or program is running via a PowerShell script. The Get-Process cmdlet will return a list of all running processes and their associated properties.

camo polo shirt said...

You can use the Get-Process cmdlet to check if a process is running via a PowerShell script. This cmdlet can be used to get a list of all processes currently running on the system, and you can pass a specific process name as a parameter to filter the results