Link to home
Create AccountLog in
Avatar of wibblar
wibblar

asked on

VB script to remotely query a service and restart if nessesary

I'm trying to get into VB scripting and would like to create a tool that will remotly query a service and then attempt to restart that service if it is not running. (this is in an XP SP2 ,moving to SP3 and W2k3 server environment)

How would I run a Dos command from Vb and pull the error code back to VB

EG
SC \\%servername% query %servicename%|findstr /i "running"

Or is there a better way to do this with purely VB?

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of philipjonathan
philipjonathan
Flag of New Zealand image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of wibblar
wibblar

ASKER

Thats exactly what i needed thank you V much

i had half worked out that i needed to use
Dim sc As New ServiceController(serviceName)

but couldn't work out how to get it to query a remote server
for an extreme n00b VB beginner the help pages arn't too helpful! :)
Thanks again!