@echo off for /f "delims=" %%t in ('winsw.exe status') do set str=%%t echo %str% if %str%==Started ( echo "restart....." winsw stop PING 127.0.0.1 -n 10 -w 30000 >NUL winsw start ) if %str%==Stopped ( echo "start....." winsw start ) if %str%==NonExistent ( echo "deploy and start....." winsw install winsw start echo c )