This Vbs script will prompt you for a remote computer name and restart the service defined in the strServiceName variable.
Note: The script uses the service name rather than the service display name however
you can change the Vbs script to use the display name by changing the line that reads:
& "Where Name='" & strServiceName & "'") To: & "Where DisplayName='" & strServiceName & "'")
VBS Script:
strComputer = InputBox ("Enter Name")
strServiceName = "WuauServ" ' Automatic Updates
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery ("Select * from Win32_Service " _
& "Where Name='" & strServiceName & "'")
For Each objService in colServiceList
objService.StopService()
Wscript.Sleep 500
objService.StartService()
Next
Wscript.Echo "The "& strServiceName & " Has Been Restarted on " & strComputer
Wscript.Quit
Additional Methods:
objService.PauseService()
Sends the named service into a paused state.
objService.ResumeService()
Sends the named service into a resumed state.
objService.InterrogateService()
Sends the named service instructions to update its state in the services applet.
objService.UserControlService()
Sends a user defined control code to the named service.
objService.Create()
Sends instructions to create a new service.
objService.Change()
Sends instructions to make modifications to the named service.
objService.ChangeStartMode()
Sends instructions to modify the start mode of the named service.
objService.Delete()
Sends instructions to remove or delete the named service.
objService.GetSecurityDescriptor()
Sends instructions to grab the security descriptor information for the named services controls access.
objService.SetSecurityDescriptor()
Sends instructions to update the version information for the security descriptor for the named services controls access.
No Comments