JSI Tip 9186. How can a script test if a service is started using only built-in commands?

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.)

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.