' ServiceStateIE.vbs ' Alan Kaplan 1-6-04 ' This script gets Service name state and startup, and displays in Internet Explorer ' based on Displaying Data with Internet Explorer, by ' Matt Goedtel, http://www.myitforum.com/articles/11/view.asp?id=6693 '========================================================================== Option Explicit Dim objIExplorer, objFileSystem, objIEPage, objWMIService Dim colServices, objService, wshshell Dim strComputer, strBorder Dim iTSview, iTableCols, pctRWidth dim strFormatOn, strFormatOff iTSview = 0 '1 for troubleshooting, allows view source menu strBorder = 1 'Best appearance is strBorder 1 'or 0 plus below uncommented ' strFormatOn = "" ' strFormatOff = "" Set wshShell = WScript.CreateObject("WScript.Shell") Set objIExplorer = CreateObject("InternetExplorer.Application") Set objFileSystem = CreateObject("Scripting.FileSystemObject") iTableCols = 3 'Number of cols strComputer = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%") strComputer = InputBox("Check Services on what computer?","Service State",strComputer) If strComputer = "" Then WScript.Quit strComputer = UCase(strComputer) 'Data to display On Error Resume next Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer& "\root\cimv2") If Err.Number <> 0 Then objIExplorer.Quit MsgBox "Error reaching or connecting to " & strComputer, vbcritical + vbinformation,"Failure" WScript.Quit Else CreateDisplay "Services on " & strComputer,"White",600,450 WriteHeader End If Set colServices = objWMIService.ExecQuery ("SELECT * FROM Win32_Service") For Each objService in colServices BeginRow WriteCell "Black", "Arial", "2", objService.DisplayName WriteCell "Black", "Arial", "2", objService.Name WriteCell "Black", "Arial", "2", objService.State WriteCell "Black", "Arial", "2", objService.StartMode EndRow Next CloseTable '================ Functions and Subs ============== Sub CreateDisplay(strTitle,strBGColor,iHeight,IWidth) objIExplorer.Navigate "about:blank" objIExplorer.AddressBar = 0 objIExplorer.Height = iHeight objIExplorer.Width = IWidth objIExplorer.MenuBar = iTSview objIExplorer.ToolBar = iTSview objIExplorer.StatusBar = 0 objIExplorer.Left = 50 objIExplorer.Top = 50 objIExplorer.Visible = 1 Do While (objIExplorer.Busy) Wscript.Sleep 250 Loop Set objIEPage = objIExplorer.Document objIEPage.Open objIEPage.Writeln "
"& strFormatOn & message & strFormatOff & " | " End Sub Sub BeginRow() objIEPage.Writeln "
" & vbcrlf & " |