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
相关推荐
数据知道4 小时前
Windows 安全基线:组策略、UAC、Defender 深度配置
windows·安全·网络安全
大模型码小白8 小时前
在 Windows 下 Codex 安装、配置与使用详细指南
java·人工智能·windows
小小龙学IT8 小时前
C++ Placement New 与显式析构:手动对象生命周期管理的艺术
c++·windows·mfc
luyun0202028 小时前
论坛里的小工具,吾爱出品
运维·服务器·windows
老王生涯10 小时前
rust开发环境配置-Windows & GNU
开发语言·windows·rust
nLif10 小时前
进程管道通讯-伪终端方式
c++·windows
CodexDave11 小时前
Python 自动化接单实战(九):Windows 免环境交付如何打包与诊断
windows·python·自动化·python自动化·pyinstaller·软件交付·windows打包
DB哥讲数据库11 小时前
【windows安装sql server教程】25步图文详解(附安装包)
windows
惠惠软件11 小时前
快速生成磁盘目录文件-双击运行a.bat ,可以看到磁盘目录下出现了 文件目录.txt-供大家学习研究参考
windows·学习·文件列表
Starmoon_dhw12 小时前
重塑你的Windows文件夹图标 Folder Theme Studio
windows