Showing posts with label powershell. Show all posts
Showing posts with label powershell. Show all posts

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