Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to list all the current running services and output it to a .csv file. Does anyone know how to do this?

share|improve this question
add comment

4 Answers

up vote 1 down vote accepted

A bit of good old shell script:

@echo off
setlocal
set SERVICES=
for /f "skip=1 tokens=*" %%S in ('%SystemRoot%\System32\net.exe start') do call :ADD_SERVICE %%S
echo Running services are : [%SERVICES%]
endlocal
goto END

:ADD_SERVICE
set SERVICE=%*
if "%SERVICE%" == "" goto END
if "%SERVICE%" == "The command completed successfully." goto END
set SERVICES=%SERVICES%%SERVICE%,
goto END

:END

share|improve this answer
    
Nice. I was trying to do that myself in a batch file, but failed miserably (and drowned my sorrows in sed, instead). –  SmallClanger Nov 19 '10 at 9:56
add comment

Might I be evil and suggest the Cygwin variant:

net start | sed -e '1,2d' -e ':a' -e N -e 's/\n  /,/' -e ta > services.csv
share|improve this answer
add comment

most basic way would to do this would be;

net start > services.csv

Sysinternals has a lot of tools which will provider more granular detailed information from within your processes. Such as PsService , the same function piping the result to a file will export as needed "> filename.extension"

share|improve this answer
    
net start > services.csv worked but what I forgot to add is that every service has to be seperated by commas. Do you know how to do this? –  Kraffs Nov 18 '10 at 15:48
    
give this a try through Powershell, Get-Process | Export-Csv c:\scripts\test.txt -force see technet.microsoft.com/en-us/library/ee176825.aspx for full documentation. –  Nick O'Neil Nov 18 '10 at 16:01
    
does powershell exist for windows server 2003? –  Kraffs Nov 18 '10 at 16:06
    
sure you can download it free, a reboot might be necessary for the server to complete installation although another option is to utilize powershell on a workstation in the same domain to execute get-process including \\computername to query another machines resources. download link on the right side of this page technet.microsoft.com/en-us/scriptcenter/powershell.aspx –  Nick O'Neil Nov 18 '10 at 16:11
    
Powershell is available for Xp and 2003 but it is not installed by default. You should be able to download it from Microsoft Update as an optional update. –  Bob Baller Nov 18 '10 at 16:11
add comment

I have a simpler command than the above examples. WMI is installed by default on Windows XP or Windows 2k3 and above, although to use the wmic.exe program, the machine may need to initialize before local operation. From a command prompt issue the command:

WMIC path Win32_Service where state='Running' get /format:csv

or, for a machine on the network:

WMIC /node:myserver Win32_Service where state='Running' get /format:csv

Redirect the output to a file of your choice.

Changing /format:csv to /format:list makes a human readable output. One of my servers gives this for its HP Insight service:

AcceptPause=TRUE
AcceptStop=TRUE
Caption=HP Insight Storage Agents
CheckPoint=0
CreationClassName=Win32_Service
Description=HP Insight Storage Agents
DesktopInteract=FALSE
DisplayName=HP Insight Storage Agents
ErrorControl=Normal
ExitCode=0
InstallDate=
Name=CqMgStor
PathName=C:\WINDOWS\system32\CpqMgmt\cqmgstor\cqmgstor.exe
ProcessId=1836
ServiceSpecificExitCode=0
ServiceType=Own Process
Started=TRUE
StartMode=Auto
StartName=LocalSystem
State=Running
Status=OK
SystemCreationClassName=Win32_ComputerSystem
SystemName=CRL500
TagId=0
WaitHint=0

Most likely, you have no interest in many of these attributes and values. Assuming you only want Name, Caption and Pathname for each running process, you might issue the following command specifying only these attributes:

WMIC /node:myserver path Win32_Service where state='Running' get name,caption,pathname /format:csv

Rob

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.