Wednesday, June 27, 2018

Check if a process is running



#See if Excel is running.
#Do not exit until it is not running.

$CheckExcelRunning=Get-Process | select -ExpandProperty  processname

While ($CheckExcelRunning -contains "EXCEL")
    {
    $CheckExcelRunning=Get-Process | select -ExpandProperty  processname

        if ($CheckExcelRunning -contains "EXCEL")
            {
            #Wait 5 minutes before next check
            start-sleep -S 300
            }
 
     }

exit