I’ve got a particular program running on a Windows 2012 R2 server that seems to crash from time to time, removing the ability for users to switch TV channels on the floor of our business. Whenever this happens, I simply have to start the program on the server and functionality is restored.<\/p>\n
I’d like to automate this process, so that the server can monitor the program itself, and restart it if it’s not running. The program does not run as a service.<\/p>\n
Is there a way to configure the program to run as a service without a third party application? (I don’t want to expand the potential problem domain with yet another program)<\/p>\n
I’ve thought about using a powershell script launched regularly by a scheduled task to check if the process is running and restart if not. Any advice on doing this or am I overlooking a simpler solution?<\/p>\n
If I can get it running as a service then I could obviously use the failover conditions to relaunch the service if it crashes…<\/p>\n
Thanks for your help.<\/p>","upvoteCount":10,"answerCount":7,"datePublished":"2019-06-16T15:10:00.000Z","author":{"@type":"Person","name":"ryanbrad","url":"https://community.spiceworks.com/u/ryanbrad"},"acceptedAnswer":{"@type":"Answer","text":"
You can create a simple task with a batch file that launches it every five minutes. In case it is already rnning, the batch terminates:<\/p>\n
tasklist | findstr /i your.exe && goto end \nc:\\path\\to\\your.exe \n:end\n<\/code><\/pre>","upvoteCount":2,"datePublished":"2019-06-16T15:43:12.000Z","url":"https://community.spiceworks.com/t/auto-restarting-a-program-if-it-crashes/716624/2","author":{"@type":"Person","name":"spiceuser-g7ncs","url":"https://community.spiceworks.com/u/spiceuser-g7ncs"}},"suggestedAnswer":[{"@type":"Answer","text":"I’ve got a particular program running on a Windows 2012 R2 server that seems to crash from time to time, removing the ability for users to switch TV channels on the floor of our business. Whenever this happens, I simply have to start the program on the server and functionality is restored.<\/p>\n
I’d like to automate this process, so that the server can monitor the program itself, and restart it if it’s not running. The program does not run as a service.<\/p>\n
Is there a way to configure the program to run as a service without a third party application? (I don’t want to expand the potential problem domain with yet another program)<\/p>\n
I’ve thought about using a powershell script launched regularly by a scheduled task to check if the process is running and restart if not. Any advice on doing this or am I overlooking a simpler solution?<\/p>\n
If I can get it running as a service then I could obviously use the failover conditions to relaunch the service if it crashes…<\/p>\n
Thanks for your help.<\/p>","upvoteCount":10,"datePublished":"2019-06-16T15:10:00.000Z","url":"https://community.spiceworks.com/t/auto-restarting-a-program-if-it-crashes/716624/1","author":{"@type":"Person","name":"ryanbrad","url":"https://community.spiceworks.com/u/ryanbrad"}},{"@type":"Answer","text":"
Scheduling a task that checks to see if the service (or exe) is running is a band-aid. Determining why something fails and then resolving that issue is the proper methodology<\/p>","upvoteCount":3,"datePublished":"2019-06-16T16:37:47.000Z","url":"https://community.spiceworks.com/t/auto-restarting-a-program-if-it-crashes/716624/3","author":{"@type":"Person","name":"jcLAMBERT","url":"https://community.spiceworks.com/u/jcLAMBERT"}},{"@type":"Answer","text":"
Should be able to create it as a service.<\/p>