This VBS script will take a machine name from an input dialog box and list the services and the account which they are running under and send the results to an excel spreadsheet.
Note: Change the line that reads: Set colItems = objWMIService.ExecQuery("Select * from Win32_Service") To: Set colItems = objWMIService.ExecQuery("Select * from Win32_Service Where StartName = 'LocalSystem'") to see the services running under the Local System account. If you want to list the services and their respective accounts that are not running under the local system account which for servers can be quite a large list change the line to: Set colItems = objWMIService.ExecQuery("Select * from Win32_Service Where StartName <> 'LocalSystem'")
VBS Script:
strComputer = InputBox ("Enter Machine Name")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Service Name"
objExcel.Cells(1, 2).Value = "Account Name"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objItem in colItems
objExcel.Cells(intRow, 1).Value = objItem.Name
objExcel.Cells(intRow, 2).Value = objItem.StartName
intRow = intRow + 1
Next
objExcel.Range("A1:B1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done"
No Comments