Windows 应用程序监控重启

执行思路 1.定时关闭可执行程序,2.再通过定时监控启动可执行程序

定时启动关闭程序.bat

csharp 复制代码
@echo off
cd "D:\xxxx\" :: 可执行程序目录
Start "" /b xxxx.exe  :: 可执行程序
timeout /T 600 /nobreak >nul :: 600秒
taskkill /IM xxxx.exe /F  :: 可执行程序关闭
exit

监控程序.bat

csharp 复制代码
@echo off
:run
:: 标题定义
title 监控程序
:: 当前路径
set strPath=%~dp0
:: 带绝对路径的文件名
set strFile=%strPath%%date:~0,4%%date:~5,2%%date:~8,2%.log
:: 输出时间到文件
echo [%time%] >>%strFile%
:: 输出计算器的进程信息到文件
:: tasklist -nh -fo csv -fi "IMAGENAME eq 定时启动关闭程序.bat" >>%strFile%
tasklist -fi "IMAGENAME eq 定时启动关闭程序.bat" >>%strFile%
:: 下面是检查进程是否存在,不存在启动当前路径下的脚本文件1.bat
tasklist|find /i "xxxx.exe"
if %errorlevel%==0 (
	echo 采集webapi程序已启动
) else (
	echo 采集webapi程序不存在,启动
	start  /d"D:/bat地址目录" 定时启动关闭程序.bat
)
:: 定时5秒
choice /t 5 /d y /n >nul
goto run
相关推荐
x***r15111 小时前
Zotero7.0.8 文献管理安装步骤详解(附文献管理与同步设置教程)
windows
何中应13 小时前
解决Windows CMD中文乱码问题
windows·操作系统
何中应13 小时前
Windows打开命令窗口的几种方式
windows·操作系统
水饺编程17 小时前
第4章,[标签 Win32] :TextOut 测试案例2
c语言·c++·windows·visual studio
i建模17 小时前
Omarchy挂载windows磁盘
linux·运维·windows
A懿轩A19 小时前
【Java 基础编程】Java 集合框架详解:List/Set/Map 选型 + ArrayList/HashMap 原理与使用
java·windows·list
ol木子李lo19 小时前
Linux 命令备忘录
linux·运维·服务器·windows·编辑器·ssh·bash
三无少女指南20 小时前
开发者环境配置最佳实践:编辑器Cursor ,VS Code的上位体验实现 AI 与 WSL 联动
运维·c语言·数据库·windows·git·编辑器
水木姚姚21 小时前
string类(C++)
开发语言·c++·windows·vscode·开发工具
【ql君】qlexcel1 天前
Windows使文件的视图默认按详细信息显示
windows·文件夹·详细信息·文件的视图·默认查看·默认视图·查看方式