How to restart program automatically if it crashes in Windows?

前端 未结 7 1309
走了就别回头了
走了就别回头了 2020-12-30 05:56

How can I start my program automatically if it crashes on windows 2003 server? Sometimes my program just crashes, is there a way in windows or settings that I can set?

相关标签:
7条回答
  • 2020-12-30 06:22

    There are several ways to create a process supervisor/guardian process on Windows. First, is to leverage windows command line capabilities. Create a bat file:

    @echo off
    :start
    start /w "your app to watch.exe"
    goto start
    

    start /w will wait for the process to exit. When the process crashes and exits, the bat script will relaunch it.

    Another option is to use free supervisor tool https://github.com/chebum/Supervisor. It allows to restart the crashed app, plus it allows to monitor two or more apps at once and it will automatically close these apps when supervisor's window is closed.

    0 讨论(0)
提交回复
热议问题