windows 之 bat 实现进程守护
参考信息:
windows下批处理实现进程监测 http://blog.51cto.com/10942560/2096009
.bat批处理命令常用操作 https://blog.csdn.net/zhanglu_1024/article/details/79595008
进程守护: protect_my_process.bat,文件保存编码为 ANSIC 码
@echo off
:RESTART
REM cd 到程序的目录下,防止其他问题出现
cd /d E:
cd /d E:\yinzhuoqun\
REM 查找要运行软件进程名称是否存在
tasklist /nh|find /i "my_process.exe"
REM 有则啥事不干,没有则启动该程序
If ERRORLEVEL 1 (start E:\yinzhuoqun\my_process.exe) else (echo 程序已运行)
REM 延时 10 * 2000 = 20s
ping -n 10 -w 2000 127.0.0.1 > tblm_temp.txt
REM 重新启动
goto RESTART
隐藏 bat 脚本启动的 CMD 窗口: hide_cmd_window.vbs
CreateObject("WScript.shell").Run"cmd /c E:\yinzhuoqun\protect_my_process.bat",0
或
CreateObject("C:\Windows\System32\wscript.exe").Run"cmd /c E:\yinzhuoqun\protect_my_process.bat",0
windows 开机自启的启动目录
vbs、bat 脚本以及 快捷方式 放入自启动目录,开机便会自动启动
C:\Users\{你的用户名}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
说明
python 脚本可以用 pyinstaller 打包成 exe,然后使用以上方法实现进程守护。
相关文章
- windows无exe
- 彻底解决docker在windows上的端口绑定问题
- Windows端口被占用_windows如何打开端口
- 8080端口被system占用_windows端口被占用但找不到进程
- 【微软2019高潜开源项目】Windows Terminal开发者内测版简易安装教程
- Windows下安装和部署SVN服务器且同步到Web站点的图文教程
- windows共享文件创建----局域网办公
- 【错误记录】Windows 控制台程序编译报错 ( WINDOWS.H already included. MFC apps must not #include <Windows.h> )
- EasyCVR新增:Windows系统下托盘可显示进程图标
- Windows Live Writer 简单使用
- windows虚拟机 VMware软件中文版安装包下载,VMware安装激活
- 轻松架设Windows 2003用户隔离FTP站点的注意事项
- 在Windows XP系统安装SQL server 2000 企业版(图解版)
- 用Python杀掉windows平台下的进程详解编程语言
- 和 windowsC语言在连接Linux与Windows之间的作用(c连接linux)
- windows从Mingw到Linux,再到Windows:一程多操作系统之旅(mingwlinux)
- windows比较Linux与Windows:谁占上风?(linuxvss)
- 微软发布带外更新修复Windows 10使用非标智能卡时无法打印的问题
- windows 混合操作系统:CASTEp同时兼容Linux和Windows(casteplinux)
- 、windows切换就出:双系统 Linux 与 Windows(双系统linux)
- 在Windows环境下实现Redis服务安装(windows下安装redis)
- and windows切换Linux和Windows系统:实现自由转换(swaplinux)
- 和windows双系统安装:Linux与Windows并存(安装双系统linux)
- 在Windows 11最新预览版中微软已对窗口残留的边框白色像素进行修复
- Windows实现连接Linux的新方式(windows连接linux)
- Linux远程控制Windows:让你的操作变得更轻松(linux远程windows)
- Linux挂载Windows共享:实现无缝网络体验(linux挂载windows共享)
- Linux与Windows的差异:显而易见的对比(linux与windows的区别)
- 在Linux系统中安装Windows:自由选择的另一种可能性(linux下安装windows)