Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Windows automatically start if program fails

  • 15-08-2007 9:17am
    #1
    Registered Users Posts: 1,557 ✭✭✭


    On windows how do I get the system to automatically start a program if this particular program fails or stops running?

    Is there a way to do that?


Comments

  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Not really for bog standard programs.

    Windows runs a number of services - these are programs which run in the background and work away doing their thing. Windows maintains a list of these services - what they're called, where the executable is, whether they get started at boot time, or on demand, etc etc.

    A particular windows program called the Service Host, monitors and controls these services. So if you can get your program to run as a service, then you can tell the service host what actions to take in the event that the program crashes or stops running. This includes running another program.

    You can use the sc command to create a windows service from an executable:
    http://support.microsoft.com/kb/251192

    There are no doubt a number of criteria that the program must have to run as a service - usually these programs must be completely autonomous - i.e. you can't have a service with a GUI.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    This really belongs in the Windows forum.


  • Registered Users Posts: 1,557 ✭✭✭quinnd6


    The program in question is a perl script though so not sure if I could make that a service


  • Registered Users, Registered Users 2 Posts: 23,212 ✭✭✭✭Tom Dunne


    quinnd6 wrote:
    The program in question is a perl script though so not sure if I could make that a service

    One option would be to have a scheduled task that checks if the perl script is running and restart it if it isn't.


  • Registered Users Posts: 1,557 ✭✭✭quinnd6


    I dont know how to get scheduled tasks to check if a program is already running and if it isnt run it.
    Would I have to use a batch file to do this?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 23,212 ✭✭✭✭Tom Dunne


    quinnd6 wrote:
    Would I have to use a batch file to do this?

    You could set up a batch file to run at certain intervals, say every 10 minutes to see if the other script is running.

    In fact, you could have a batch file to call a perl script to check if the original perl script is running. :)


  • Registered Users Posts: 1,557 ✭✭✭quinnd6


    Only problem is I dont know perl and dont know too much about batch files either.


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    If you could compile the perl script into an executable, then in theory you could use that to create a service.


  • Registered Users, Registered Users 2 Posts: 23,212 ✭✭✭✭Tom Dunne


    quinnd6 wrote:
    Only problem is I dont know perl and dont know too much about batch files either.

    Well now is a good time to learn. :)

    Look for pstools on Microsoft's website. Use the pslist command, in a batch file, to check for an instance of perl.exe running. If it is not running, start up the perl script that you require.

    Start off by using pslist on it's own (i.e. at the command line, not in a batch file). When you get that working, then put it into a batch file and schedule it as required.


Advertisement