开发者

Simple program to restart another program on certain condition

开发者 https://www.devze.com 2023-03-17 06:32 出处:网络
Basically I need to restart a program if it quits with a value other than zero. I believe it will be a simple program probably can be made wi开发者_开发知识库th a few lines of code in a BAT file. I\'

Basically I need to restart a program if it quits with a value other than zero.

I believe it will be a simple program probably can be made wi开发者_开发知识库th a few lines of code in a BAT file. I'm wondering if someone has already written similar program and want to share it.


In Python:

import subprocess

while True:
    rc = subprocess.call('program.exe')
    if rc == 0:
        break


This is a simple example in Batch:

:a
program.exe
IF NOT %ERRORLEVEL% EQU 0 GOTO a
0

精彩评论

暂无评论...
验证码 换一张
取 消