This script will help to check if the srevice is avilable or not in a group of system
'============================================================================================'Script Written by Sudheesh Narayanaswamy'This can be used to check if the srevice is avilable or not in a group of system'Create a file called input.txt (location speiced in strFile) with computer name of the system each line having one server name'Name the service which you want to check in the Varable sService (Disaply Name of service)'The out file will be the loaction specified in the strReport variable'==============================================================================================Option ExplicitOn Error Resume Nextconst strReport = "c:\TEST\OUTPUT.txt"const sFile = "C:\TEST\INPUT.txt"const sService = "XXXXXXXXXXXXXXXXXX"Dim objWMIService, objItem, colItemsDim colListOfServices,strServiceList,objServiceDim strDriveType, strDiskSize, txtDim oFSO, oFile, sText,strComputerSet oFSO = CreateObject("Scripting.FileSystemObject")Dim objFSO,objTextFileSet objFSO = createobject("Scripting.FileSystemObject")Set objTextFile = objFSO.CreateTextFile(strReport)strServiceList="Service Not installed"If oFSO.FileExists(sFile) Then Set oFile = oFSO.OpenTextFile(sFile, 1)
txt = "Computer Name" & vbtab & vbtab &"Service Name" & vbtab & vbtab & "Service Status" & vbcrlf objTextFile.Write(txt)txt = "==============" & vbtab & vbtab & "==============" & vbtab & vbTab & "================" & vbcrlf objTextFile.Write(txt)
Do While Not oFile.AtEndOfStream sText = oFile.ReadLine If Trim(sText) <> "" Then strComputer=sText txt=" "
Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _ ("Select * from Win32_Service ") If Err = 0 Then ' WMI and VBScript loop For Each objService in colListOfServices If objService.DisplayName=sService1 then txt="" strServiceList = objService.DisplayName & VbTab & objService.State txt = strComputer & vbtab & vbtab & strServiceList & vbcrlf objTextFile.Write(txt) End If
Next else strServiceList="System Not Reacheable" Err.Clear End If
End IFLoopobjTextFile.CloseoFile.CloseElseWScript.Echo "Create a input file was not there."End If Hope this helps