JSI Tip 9695. How can I generate a CSV file containing the key and display name of running services?

Jerold Schulman

August 31, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today


Using REG.EXE, built into Windows XP, Windows Server 2003, and later, or installed on Windows 2000 from the Support Tools folder of of the Windows 2000 CD-ROM, I have scripted RunSvc.bat to generate a CSV (Comma Separated Value) file containing the Key and display name of running services. The output is written to RunSvc.csv in the current directory.

The syntax for using RunSvc.bat is:

RunSvc

RunSvc.bat contains:

@echo offsetlocalif exist RunSvc.csv del /q RunSvc.csvset work="%TEMP%RunSvc_%RANDOM%.TMP"set OK="HKEY_LOCAL_MACHINESystemCurrentControlSetServices"set qry=REG QUERY HKLMSystemCurrentControlSetServicesif exist %work% del /q %work%for /f "Skip=1 Tokens=*" %%a in ('net start^|find /v "The command completed successfully."') do ( @echo %%a>>%work%)for /f "Tokens=*" %%a in ('%qry%^|find /i %OK%') do ( call :getsvc "%%a">nul 2>&1)del /q %work%endlocalgoto :EOF:getsvcfor /f "Tokens=1,2*" %%b in ('REG Query %1 /V DisplayName^|Find "REG_SZ"^|Findstr /i /g:%work%') do (  @echo %1,"%%d">>RunSvc.csv)



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like