You can use the start command to test if a service is started, using the service DisplayName.
NOTE: If you only know the service short name, see see tip 9136 » How can a script return the service display name and service short name, sorted by service display name?
If you open a CMD.EXE window and type Net Start, it displays the DisplayName of all the services that are started.
To use this behavior in a script, assume you wanted to test if the Print Spooler service was started:
net start|find /i "Print Spooler">nul if %ERRORLEVEL%==0 (@echo The Print Spooler is started.) else (@echo The Print Spooler is NOT started.)
0 comments
Hide comments