Skip to content

Instantly share code, notes, and snippets.

@macdylan
Created February 13, 2015 07:09
Show Gist options
  • Save macdylan/55500f05c66c6b122002 to your computer and use it in GitHub Desktop.
Save macdylan/55500f05c66c6b122002 to your computer and use it in GitHub Desktop.
windows daemon
@echo off
set task=programname
set srv=z:/path/programname.exe
set srv_dir=z:/path
set pwd=%CD%
:CHECK
for /f "tokens=5" %%n in ('qprocess.exe ^| find "%task%"') do (
if %%~nn==%task% (goto ALIVE) else (goto START)
)
:START
echo [%time%] restarting ...
cd %srv_dir%
start %srv%
cd %pwd%
ping.exe /n 5 127.0.0.1 > nul
goto CHECK
:ALIVE
echo [%time%] process is alive, keep going ...
ping.exe /n 10 127.0.0.1 > nul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment