繁体   English   中英

在批处理文件中创建看门狗并在启动时运行它

[英]Create Watchdog in a batch file and run it on startup

我编写了这段代码来在应用程序崩溃时重新启动它:

@ECHO OFF
:B
SET MyProcess=AL.Distributore.exe
TASKLIST | FINDSTR /I "%MyProcess%"
IF ERRORLEVEL 1 (GOTO :StartScripts) ELSE (timeout 120 /nobreak >nul)
GOTO :B 

:StartScripts 
::: //-- Put in the full path to the batch scripts to call
::: //-- Be sure the security context this process runs as has access to execute the below-called batch scripts
if exist D:\Acqualogica\Applicazione\AL.Distributore.exe (START D:\Acqualogica\Applicazione\AL.Distributore.exe)
GOTO :B 

如果我从双击开始它工作正常,但我需要在 PC 启动时在后台运行它。 我尝试将快捷方式放入C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup ,在寄存器中创建一个用于自动启动的密钥,但没有任何启动(或工作)。

操作系统:Windows 7

我该怎么做?

您可以使用任务计划程序执行此操作。 可以使用 Windows 设置或命令行(使用schtasks.exe ( /SC OnStart ))配置此功能,但首先,我建议您使用 Windows 设置工具(在“触发器”部分,您将见“OnStart”可能性)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM