Skip navigation

Q. How can I script a CSV display of Service State, Service Short Name, and Service Display Name?

I have scripted Svcs.bat to display the state, key, and Display Name of all services on your computer.

The syntax for running Svcs.bat is:


The output might begin with:

"RUNNING","ALG","Application Layer Gateway Service"
NOTE: Svcs.bat uses SC.exe, installed by default on Windows XP, Windows Vista, and Windows Server 2003, or installed from the Resource Kit on Window 2000.

Svcs.bat contains:

@echo off
sc query state= all | findstr /i "Service_Name Display_Name State" >"%TEMP%\svcs.tmp"
for /F "tokens=*" %%* in ('type "%TEMP%\svcs.tmp"') do call :Sub %%*
del /f /q "%TEMP%\svcs.tmp"
goto :EOF
set p1=%*
set p1=%p1:(=\[%
set p1=%p1:)=\]%
if /i %p1:~0,8%

Service_ set s2="%p1:~14%" if /i %p1:~0,8%

Display_ set s3="%p1:~14%" if /i %p1:~0,5%

State set s1="%p1:~24%" if /i %p1:~0,5%

State echo %s1%,%s2%,%s3%

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.