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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript to Stop or Start a service 1

Status
Not open for further replies.

iCougari

IS-IT--Management
Jul 30, 2003
13
US
Hi all,

Thanks for reading this and i hope that someone will be able to help.

I need a script that will stop a service wait for about 5 seconds and then restart it. The script can sit locally on the machine.

Hope you can help.

Thanks

James aka IcougarI
 
Do a keyword search in this forum for service stop

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
how to stop a service

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objComputer = GetObject("WinNT://" & WshNetwork.ComputerName & ",computer")

Set objService = objComputer.GetObject("service", "clisvc")
If objService.Status = 4 Then
objService.Stop
End If
Wscript.Sleep 'some time here
objService.Start

Set objService = Nothing
Set objComputer = Nothing
Set WshNetwork = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top