We help IT Professionals succeed at work.

How to list automatic services and its status using VBS?

acunaara
acunaara asked
on
How to list automatic services and its status:

Example:
ActivIdentity Shared Store Service                        Running
Adobe Acrobat Update Service                              Running
AgentService                                              Running
Windows Audio Endpoint Builder                            Running
Windows Audio                                             Running
Base Filtering Engine                                     Running
Background Intelligent Transfer Service                   Running
Certificate Propagation                                   Running
Microsoft .NET Framework NGEN v4.0.30319_X86              Stopped
Microsoft .NET Framework NGEN v4.0.30319_X64              Stopped
Comment
Watch Question

Most Valuable Expert 2012
Top Expert 2014
Commented:
Hi, this is a VBScript version:
strOutput = "AllAutomaticServices.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutput = objFSO.CreateTextFile(strOutput, True)
objOutput.WriteLine """Service Name"",""State"""
strComputer = "."
Set colServices = GetObject("winmgmts:\\" & strComputer & "\root\cimv2").ExecQuery("SELECT * FROM Win32_Service WHERE StartMode='Auto'")
For Each objService In colServices
	objOutput.WriteLine """" & objService.Caption & """,""" & objService.State & """"
Next
objOutput.Close
WScript.Echo "Done. Please see " & strOutput

Open in new window


and this is a Powershell version:
Get-WmiObject -Query "SELECT Caption,State FROM Win32_Service WHERE StartMode='Auto'" | Select Caption,State | Export-CSV -Path "C:\Temp\Scripts\AllAutomaticServices.txt"

Open in new window


Regards,

Rob.

Author

Commented:
Thanks