VB Script to get list of services into an Excel list
Borrowing some code from the following from the TechNet Script Repository for Office:
I was able to make a little VB Script app that lists all of the services on my Windows XP box, format the column headers, and mark each stopped service in red. Yes, you can get the same info in many other ways, but this way is in Excel, which is one of my favorite applications.
Save the following code to a .vbs file and run it from the command line:
' Create a new and blank spreadsheet:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
' Format the cell A1 and add the text: Service
objExcel.Cells(1, 1).Value = "Service"
objExcel.Cells(1, 1).Font.Bold = TRUE
objExcel.Cells(1, 1).Interior.ColorIndex = 43
objExcel.Cells(1, 1).Font.ColorIndex = 2
' Format the cell A1 and add the text: Status
objExcel.Cells(1, 2).Value = "Status"
objExcel.Cells(1, 2).Font.Bold = TRUE
objExcel.Cells(1, 2).Interior.ColorIndex = 50
objExcel.Cells(1, 2).Font.ColorIndex = 2
' Find the Windows services on this computer
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServices = objWMIService.ExecQuery _
("Select * From Win32_Service")
' Write each service to Excel, starting in A2
x = 1
For Each objService in colServices
x = x + 1
objExcel.Cells(x, 1) = objService.Name
objExcel.Cells(x, 2) = objService.State
if objService.State = "Stopped" then
objExcel.Cells(x, 2).Font.ColorIndex = 3
' Autofit the first column to fit the longest service name