Monday, August 11, 2014

Check for Running Task & Start

We have an open source Application call iSpy Connect that monitors all of the IP cameras in the building. This software (because we aren't paying for the licensed version) runs as a standard application and not as a service. This causes issues when someone logs into the server to check a recording and closes the Application or logs out. Now the software isn't running which means it isn't recording camera activity. I wrote this powershell script to check to see if the service was running. If it's running it just closes... if it's not running it will start the application. It looks like this -
#Process Name
$procToCheck = "iSpy"

#Process exe location
$procFileExe = "C:\Program Files\iSpy\iSpy (64 bit)\ispy.exe"

#Checks for running process and starts if needed 
$process = Get-process $procToCheck
if (!($process)) {
 start-process $procFileExe
}
And added a 15 minute task in Task Scheduler following these steps: Create Basic Task Name Task and Description Schedule it Daily Run it Every Day Start a Program Program/Script: powershell.exe Add arguments (optional): -file "c:\scripts\ispy_Running.ps1" Check the box to open the Properties dialog for this task when clicking Finish Double click the trigger created to edit the trigger Check the box to Repeat the task every: - And set it to 15 minutes or whatever is appropriate Change the duration to Indefinite Save your changes and that should create a task that will monitor for your program running and start it should it close (or be closed)

No comments:

Post a Comment

Remote Mailboxes - Hybrid Config - Missing

The Remote Mailbox exists on the On Prem Exchange server and linked to the Office 365 mailbox. Without one of these for each Office 365 mail...