(view source code of servicestd.vbs as plain text)
' ServicesTD.vbs, Version 1.00
' Display all services installed in a TAB delimited format.
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
' Check command line parameters
Select Case WScript.Arguments.Count
Case 0
' Default if none specified is local computer (".")
Set objWMIService = GetObject( "winmgmts://./root/cimv2" )
Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )
For Each objItem in colItems
strComputer = objItem.Name
Next
Case 1
' Command line parameter can either be a computer name
' or "/?" to request online help
strComputer = Wscript.Arguments(0)
if InStr( strComputer, "?" ) > 0 Then Syntax
Case Else
' Maximum is 1 command line parameter
Syntax
End Select
On Error Resume Next
' Query and display running processes
Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
' Display error number and description if applicable
If Err.Number Then
strMsg = vbCrLf & "Error # " & Err.Number & vbCrLf & _
Err.Description & vbCrLf & vbCrLf
Syntax
End If
' Collect information on services
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service",,48)
' Set header for screen output
strMsg = "Name:" & vbTab _
& "DisplayName:" & vbTab _
& "PathName:" & vbTab _
& "StartMode:" & vbTab _
& "State:" & vbTab _
& "StartName:" & vbCrLf
' List all services and their properties
For Each objItem in colItems
strMsg = strMsg _
& objItem.Name & vbTab _
& objItem.DisplayName & vbTab _
& objItem.PathName & vbTab _
& objItem.StartMode & vbTab _
& objItem.State & vbTab _
& objItem.StartName & vbCrLf
Next
' Display the results
Wscript.Echo strMsg
' Done
WScript.Quit(0)
Sub Syntax
msg = vbCrLf & "ServicesTD.vbs, Version 1.00" & vbCrLf _
& "Display all services for any WMI enabled computer on the network" _
& vbCrLf & "in a TAB delimited format." _
& vbCrLf & vbCrLf _
& "Usage: CSCRIPT SERVICESTD.VBS [ computer_name ]" _
& vbCrLf & vbCrLf _
& "Where: " & Chr(34) & "computer_name" & Chr(34) _
& " is the name of the computer to whose services" & vbCrLf _
& " are to be displayed (without leading backslashes)." _
& vbCrLf & vbCrLf _
& " Default is " & Chr(34) & "." & Chr(34) _
& " (the local computer)." _
& vbCrLf & vbCrLf _
& "Written by Rob van der Woude" & vbCrLf _
& "http://www.robvanderwoude.com" _
& vbCrLf & vbCrLf _
& "Created using Microsoft's Scriptomatic tool" & vbCrLf _
& "http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/WMImatic.asp"
Wscript.Echo(msg)
Wscript.Quit(1)
End Sub
page last modified: 2024-04-16; loaded in 0.0082 seconds