Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript to check for service

Status
Not open for further replies.

adminguy

MIS
Apr 7, 2004
2
0
0
US
I am looking for a VBScript to check for a specific service running on the PC (Cisco Security Agent) The result (True/False) would be added to a text file on a network drive along with the computer's name. I have about 600 PCs to check and wanted to save some shoe leather.
Thanks
 
try this to start with:

Code:
function checkservice (strComputer, strService)
	Dim objWMIService, ColServiceList, objService
	Set objWMIService = GetObject("winmgmts:" _
	    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
	Set colServiceList = objWMIService.ExecQuery _
	        ("Select * from Win32_Service where Name='" & strService & "'")
	checkservice = False
	For each objService in colServiceList
	    if objservice.status = "started" Then checkservice = True
	Next
End Function

You can use the FileSystemObject to do the writing to a textfile...

Please tell me if I'm wrong I like to learn from my mistakes...
_____________________________________
Feed a man a fish and feed him for a day.
Teach a man to fish and feed him for a lifetime...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top