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>