code_junkie

Checking if an application is still running from a batch file?

Nov 12th, 2011
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. @echo off
  2.  
  3. CommandYouWillRun.exe
  4.  
  5. rem waiting for the process to start
  6. :startcmd
  7. sleep 1
  8. c:pathtopslist.exe CommandYouWillRun > NUL
  9. IF ERRORLEVEL 1 goto startcmd
  10.  
  11. rem the process has now started
  12.  
  13. :waitforcmd
  14. sleep 1
  15. c:pathtopslist.exe CommandYouWillRun > NUL
  16. IF ERRORLEVEL 1 got finished
  17. goto waitforcmd
  18.  
  19. :finished
  20. echo "This is an error message"
Add Comment
Please, Sign In to add comment