How to set into disabled state a Windows service using VBS?

How to set into disabled state a Windows service using VBS?



You can use sc from a command prompt or batch file:
sc config serviceName start=disabled



You can use sc from a command prompt or batch file:
sc config serviceName start=disabled



or that

sComputer = "."
aTargetSvcs= Array("SERVICE1","SERVICE2","SERVICE3")

Set oWMIService = GetObject("winmgmts:" & "{impersonationlevel=impersonate}!\" _
& sComputer & "rootcimv2")
Set cServices = oWMIService.ExecQuery("SELECT * FROM Win32_Service")

For Each oService In cServices
For Each sTargetSvc In aTargetSvcs
If LCase(oService.Name) = LCase(sTargetSvc) Then

If oService.State <> "Stopped" Then
oService.StopService()
End If

If oService.StartMode <> "Disabled" Then
oService.ChangeStartMode("Disabled")
End If

End If
Next
Next



Awesome





Share this

Related Posts

There was an error in this gadget