Take the 2-minute tour ×

I'm currently looking for the best way to manage a service start/stop under windows.

I will use the task sheduler provided by windows to start a script at a specific time.

The goal of the script is to :

  • check if the process "X" is running
  • if not service Y can be started
  • if yes, check in one hour if the process "X" is still running

And also what is the best language to do it ? Is Python a good choice ?


share|improve this question
I would recommend WMI for managing services under Windows. But this might be overkill for what you want... –  Sander Jan 17 '13 at 16:19
add comment

1 Answer

Here is a batch script (save as .bat)

tasklist /nh /fi "imagename eq x.exe" | find /i "x.exe" >nul && goto :HOURCHECK || net start Y
exit >nul    
timeout /t 3600
tasklist /nh /fi "imagename eq x.exe" | find /i "x.exe" >nul && REM Running || REM Not Running

Just replace my REM comments to do what you want when it checks after an hour.

share|improve this answer
add comment

Your Answer


