Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Batch processing implements process monitoring under windows to prevent the process from shutting down automatically

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The company has a Windows server 2003, and recently made a night maintenance restart plan. Server has two bearer services. These two sets of software do boot automatically, but often boot does not start or break down automatically. Now, in order to solve this problem, we have made a batch file to achieve constant monitoring.

It is implemented by two methods, both of which are bat execution files

1. Check once directly, start if you don't run, and quit if you run! (here use Baidu cloud disk to test, that is, baidunetdisk.exe)

Tasklist / nh | find / I "baidunetdisk.exe"-the name of the software process to be run

If ERRORLEVEL 1 (start D:\ Users\ Administrator\ AppData\ Roaming\ baidu\ BaiduNetdisk\ baidunetdisk.exe) else (exit)-execute the software directory and execution file without this process, otherwise exit

2. Monitor online all the time. Whenever the process is disconnected or not running, it will be turned on automatically, which can be realized by using a dead loop.

@ echo off

: RESTART

Echo # # always monitor, do not turn off! #

Tasklist / FI "username eq administrator" | find / C "baidunetdisk.exe" > baiduyunpan.txt-baidunetdisk.exe is the name of the software process to be run

Set / p num=

< baiduyunpan.txt ------------------baiduyunpan.txt运行输出文档,多进程temp.txt全文名称要都修改 del /F baiduyunpan.txt echo %num% if "%num%" == "0" start /D "D:\Users\Administrator\AppData\Roaming\baidu\BaiduNetdisk" baidunetdisk.exe --------------------软件存放目录+执行文件 ping -n 10 -w 2000 127.0.0.1 >

Baiduyunpan.txt-here is the use of PING to solve the stop time

Del / F baiduyunpan.txt

Goto RESTART

2 extension: this execution will display the CMD.EXE window, in order to hide, you can use a simple VB statement to hide the cmd window, you can see a cmd running process in the process

Step: write the second .bat file, create a XX.vbs file in the same folder, and edit

CreateObject ("WScript.shell") .Run "cmd / c baiduyunpan.bat", 0-the full name of the baiduyunpan.bat file

Execute XX.vbs directly after completion, and find that there is no cmd window, and you will find that there is an extra cmd window process in the process.

After doing this, add regular maintenance and run after server restart, plus double insurance!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report