Windows batch processing enables process monitoring to prevent processes from shutting down automatically

Source: Internet
Author: User

The company has a Windows Server 2003, recently did the night maintenance restart plan, the server has two hosting business, the two sets of software has to do boot auto-start, but often the boot does not start or automatic collapse now, to solve this problem has done a batch file to achieve constant monitoring

Implemented using two methods, all bat execution files

1, direct detection once, no operation is started, there is operation to quit! (Here take Baidu Cloud disk to test namely Baidunetdisk.exe)

tasklist/nh|find/i "Baidunetdisk.exe"---------------------------------to run the software process name
If ERRORLEVEL 1 (Start D:\Users\Administrator\AppData\Roaming\baidu\BaiduNetdisk\baidunetdisk.exe) Else (exit)------ ----------------------------------------------------no this process executes the software catalog and executes the file, otherwise exits

2, always on-line monitoring, as long as the process is disconnected or not running will automatically open, using the dead loop to achieve

@echo off
: RESTART
Echo ########################### #时时监控, do not close! #########################
Tasklist/fi "username EQ Administrator" | FIND/C "Baidunetdisk.exe" > Baiduyunpan.txt------Baidunetdisk.exe is the name of the software process to run
set/p num= < baiduyunpan.txt------------------baiduyunpan.txt run output document, multi-process temp.txt full-text name to be modified
del/f Baiduyunpan.txt
Echo%num%
If "%num%" = = "0" start/d "D:\Users\Administrator\AppData\Roaming\baidu\BaiduNetdisk" Baidunetdisk.exe-------------- ------Software Storage Directory + Execute file
Ping-n 10-w 127.0.0.1 >baiduyunpan.txt-----------Here is the use of ping to resolve 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 in the process of a CMD run process

Step: Write the 2nd. bat file and create a xx.vbs file under the same folder and edit
CreateObject ("Wscript.Shell"). Run "cmd/c Baiduyunpan.bat", 0---------------------full name of the Baiduyunpan.bat file
After completion of the direct execution of Xx.vbs, found no cmd window, in the process will find a more CMD window process

Finish these, then join the regular maintenance, after the server restart, and then run, plus double insurance!

Windows batch processing enables process monitoring to prevent processes from automatically shutting down

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.