Starten/Stoppen von Diensten mittels VBScript:


' ------ SCRIPT CONFIGURATION ------
strComputer = "" ' e.g. fs-rtp01 (use . for local system)
strSvcName = "" ' e.g. dnscache
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set objService = objWMI.Get("Win32_Service.Name='" & strSvcName & "'")

intRC = objService.StopService
if intRC > 0 then
 WScript.Echo "Error stopping service: " & intRC
else
 WScript.Echo "Successfully stopped service"
end if

wscript.sleep 3000

intRC = objService.StartService
if intRC > 0 then
 WScript.Echo "Error starting service: " & intRC
else
 WScript.Echo "Successfully started service"
end if

Links: http://techtasks.com/code/viewbookcode/371

Share