I am currently running a XAMPP on my server and i want to create a batch file that will basically check every 20 seconds whether the XAMPP is always running or not. If it runs the check loop should restart for next 20 seconds and so on. But if in case it detected that XAMPP is not running it should directly start the program.
Asked
Active
Viewed 565 times
0
-
3possible duplicate of [efficient way to keep checking if a program is still running with a batch script](http://stackoverflow.com/questions/25575532/efficient-way-to-keep-checking-if-a-program-is-still-running-with-a-batch-script) – wOxxOm Sep 18 '15 at 13:57
1 Answers
2
Try like this :
@echo off
Set "MyProcess=Notepad.exe"
:start
tasklist | find /i "%MyProcess%">nul && goto:wait || start %MyProcess%
goto:start
:wait
ping localhost -n 20 >nul
goto:start
Just replace Notepad.exe with the name of your program

SachaDee
- 9,245
- 3
- 23
- 33