Check service of remote systems


Need help...

A VB Script (Run from the server) to check two services on all the workstations listed at ComputerName.txt.
If found, then the computer name is written at foundService.txt.

Can some one pls help me...


0 Comments   [ + ] Show comments

Answers (6)

Posted by: jcarri06 13 years ago
Senior Purple Belt
What have you tried thus far? Where is your script failing?
Posted by: mqs 13 years ago
Senior Yellow Belt
I have a code to check the service locally but not remote....
Posted by: anonymous_9363 13 years ago
Red Belt
Let me guess...it pipes the output of NET START to a text file and then uses FIND?

What you want, done properly, is NOT a trivial task. A properly-built script would, for example, ping the machines listed in Computername.TXT (having checked that that file exists, of course...) It's certainly not something I'd do for free. If you're willing to pay, PM me. Meanwhile, a hint: WMI....
Posted by: mqs 13 years ago
Senior Yellow Belt
thx for that hint....

Am i missing something here.....in the code... it wont work though

Option Explicit
Dim objWMIService, objItem, objService1, objService2, objFSO, objserverlist
Dim colListOfServices1, colListOfServices2, strComputer, strService1, strService2, intSleep
Dim objfound, objnotfound, service1, service2
intSleep = 15000
'WScript.Echo " Click OK, then wait " & intSleep & " milliseconds"
'On Error Resume Next

strService1 = " 'WOW.EXE' "
strService2 = " 'NTVDM.EXE' "

set objFSO = CreateObject("Scripting.FileSystemObject")
Set objserverlist= objFSO.OpenTextFile("servers.txt", 1)
Set objfound= objFSO.createTextFile("found.txt", 2)
'Set objnotfound= objFSO.createTextFile("notfound.csv", 2)

Do until objserverlist.atendofstream
strComputer = objserverlist.ReadLine
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
colListOfServices1 = null
colListOfServices2 = null
Set colListOfServices1 = objWMIService.ExecQuery("Select * from Win32_Service Where Name ="& strService1 & " ")
Set colListOfServices2 = objWMIService.ExecQuery("Select * from Win32_Service Where Name ="& strService2 & " ")

For Each objService1 in colListOfServices1

For Each objService2 in colListOfServices2

if objService1 <> null or objService2 <> null then
Objfound.writeline strComputer & ","
msgbox "service found"
end if


Posted by: anonymous_9363 13 years ago
Red Belt
it wont work though Could you a little more vague?

Which of the 36 lines "won't work"?

Use the CODE tag for posting code. It can be accessed using the button marked '<%'.
Posted by: pgiesbergen 13 years ago
Orange Belt
It wont work because those two are not services but processes. And your usage of the two for loops will not help you either. Set a variable inside it and check if it is set afterwards.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ