How do I get Win7 to check if program is running and if not start it?


  1. Posts : 17
    Win 7 Ultimate 64 bit Retail
       #1

    How do I get Win7 to check if program is running and if not start it?


    I am running Win 7 64 bit Ultimate. I am trying to figure out a way to check if a program is currently running and if not to automatically start it.

    I have a program that has been shutting off randomly on me that I want to run 24/7 and it always seems to happen just after I leave for work. As a result I am trying to figure out how to have Windows check every 15 minutes or so if the program is still open and if not to automatically restart the program. The program doesn't hang but instead just shuts down so I don't need to kill the process. My google skills keep failing me.
      My Computer


  2. Posts : 25,847
    Windows 10 Pro. 64/ version 1709 Windows 7 Pro/64
       #2

    What program might you be referring to.
      My Computer


  3. Posts : 10,455
    Microsoft Windows 7 Home Premium 64-bit Service Pack 1
       #3

    You could do it with task scheduler. What you would need to do is start the task every so often with the rule not to start if already running.

    How do I get Win7 to check if program is running and if not start it?-screenshot240_2013-02-12.png
      My Computer


  4. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #4

    Create a file CheckProg.cmd with this contents:

    Code:
    :OK
    REM wait 10 seconds for an answer. Default answer=n
    choice /n /t 10 /d n
    tasklist |find "notepad.exe"
    IF %errorlevel% EQU 0 GOTO OK
    REM Not errorlevel 0 so not running. Restart it.
    C:\windows\system32\notepad.exe
    GOTO OK
    Of course replace notepad.exe with real name. And change C:\windows\system32 to real path. Also change 10 to 900 (15*60) if you want it to check every 15 minutes
    Doubleclick CheckProg.cmd and let it run. Works?
      My Computer


  5. Posts : 17
    Win 7 Ultimate 64 bit Retail
    Thread Starter
       #5

    Thanks for the quick responses. I will give it a try. I setup a task schedule so hopefully that works. I will know when I get home from work.

    Layback Bear said:
    What program might you be referring to.
    In this case it is Sabnzbd, but in the past I have had a couple other programs like TiVo Desktop and Crashplan do the same thing.
      My Computer


  6. Posts : 17
    Win 7 Ultimate 64 bit Retail
    Thread Starter
       #6

    It was working fine that first day, but now task scheduler seems to be having issues somewhat.

    I have it marked for do not start a new instance if the task is already running, but it seems to ignore that. I came home to Firefox crashed because it had a ton of new tabs opened. Even though sabnzbd is running it keeps starting it which just causes a new tab to open to load the web ui.
      My Computer


  7. Posts : 10,455
    Microsoft Windows 7 Home Premium 64-bit Service Pack 1
       #7

    Not sure if it matters, but was the original instance started the same way (by the task scheduler)?
      My Computer


  8. Posts : 17
    Win 7 Ultimate 64 bit Retail
    Thread Starter
       #8

    kado897 said:
    Not sure if it matters, but was the original instance started the same way (by the task scheduler)?
    No, I will try that and see how it goes. Thanks.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 14:33.
Find Us