' RestartServices.vbs
' Example VBScript to Restart Services
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.3 - March 20th 2005
' -----------------------------------------------------------------'
Option Explicit
Dim objShell, intShortSleep, intLongSleep
Dim strService
Set objShell = CreateObject("WScript.Shell")
' Values set
strService = " spooler"
intShortSleep = 1500
intLongSleep = 5500
' Cmd prompt opened
objShell.Run "cmd"
Wscript.Sleep intShortSleep
' Service stopped with 'Net' command
objShell.SendKeys "net stop" & strService
Wscript.Sleep intShortSleep
objShell.SendKeys "{Enter}"
Wscript.Sleep intLongSleep
' Service started with 'Net' command
objShell.SendKeys "net start" & strService
Wscript.Sleep intShortSleep
objShell.SendKeys "{Enter}"
Wscript.Sleep intLongSleep
' Cmd prompt exited
objShell.SendKeys "Exit"
Wscript.Sleep intShortSleep
objShell.SendKeys "{Enter}"
Wscript.Echo strService & " service stopped "
WScript.Quit
' End of example VBScript