Windows uses BAT batch to implement Daemon script sharing _dos/bat

Source: Internet
Author: User
Tags goto sleep system log

This article is transferred from the network, because cannot find the original author, therefore cannot know the origin. If you are lucky enough to see the original author, please contact me plus. Reproduced here first.

The last few days overtime plus crazy off, every night can not sleep. One of the core programs in the development department is that it's always going to go down on its own, and then it needs to be done by hand, and the service is so secure that I can do it, and I can't sleep at night, I can't stand it last night, remembering the shell daemon that I wrote in HP-UX This time to get a Windows under the bat version of the Daemon, then at night the idea has been very slow, called a brother let him write, went up after a good run, at least last night I sleep at ease for 7 hours.

Early in the process to improve some of the procedures, adding records and other functions.

Realize:

Check if there is Notepad, if you want to use it as your own process name, if the process is down will automatically restart (will be in the current directory to generate a start.bat)

 @echo off set _task=notepad.exe set _svr=c:\windows\notepad.exe set _DES=START.BAT:CHEC Kstart for/f "Tokens=5"%%n in (' Qprocess.exe ^| find '%_task% ') does (if%%n==%_task% (goto checkag) Else goto STARTSV R): startsvr Echo%time% echo ******** program starts ******** Echo program restarts in%time%, please check system log >> restart_service.txt Echo Start%_svr% >%_des% echo Exit >>%_des% start%_des% set/p=.<nul for/l%%i in (1 1) do set/p A=.<nul
&ping.exe/n 2 127.0.0.1>nul Echo. echo Wscript.Sleep wscript.arguments (0) >%tmp%\delay.vbs cscript//b//nologo%tmp%\delay.vbs 10000 del%_des%/q Ech 
o ******** Program boot complete ******** goto checkstart:checkag echo%time% program runs normally, 10 seconds to continue checking. echo Wscript.Sleep wscript.arguments (0) >%tmp%\delay.vbs cscript//b//nologo%tmp%\delay.vbs 10000 goto Checkstart /pre> 
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.