Scripting - Avere la lista dei servizi tramite vbs


Script per avere la lista dei servizi attivi su un pc

Option Explicit
Const LogFilename = "ServicesList.csv"
Const ForAppending = 8
Dim fso, logFile, wmiService, runningServices, service
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(LogFilename) Then
fso.DeleteFile(LogFilename)
End If
Set logFile = fSO.OpenTextFile("ServicesList.csv", ForAppending, True)
logFile.Write("Display Name;Service Name;Start Mode;Account")
logFile.WriteLine
Set wmiService = GetObject( _
"winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set runningServices = wmiService.ExecQuery( _
"Select * from Win32_Service Where State = 'Running'")
For Each service in runningServices
   logFile.Write(service.DisplayName) & ";"
   logFIle.Write(service.Name) & ";"
   logFIle.Write(service.StartMode) & ";"
   logFile.Write(service.StartName) & ";"
   logFile.WriteLine 
Next
logFile.Close
'Rilascio risorse
Set logFile = Nothing
Set fso = Nothing
Set wmiService = Nothing
Set runningServices = Nothing
Set service = Nothing

[fonte http://blogs.sysadmin.it/ermannog/archive/2010/01/05/3421.aspx]