Services in GPO

Status
Not open for further replies.

superdave1984

Repeat Offender
Messages
1,986
Location
KY
Basically where do you find services in a GPO? I want to push one out that starts certain services and stops others. It has to be there somewhere I just can't find it. And googling it made my head hurt.
 
This would be something I would do with a login script.
Here's a sample that I made a little while back.

Code:
Dim objWMIService, objItem, objService
Dim colListOfServices, strComputer, strService
strComputer = "."

strService = " 'Alerter' "

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name ="_
& strService & " ")
For Each objService in colListOfServices
   objService.StopService()
Next

If you want to start a service, just replace objService.StopService() with objService.StartService().

The only reason I had to do this is because a service was being sent a stop signal depending on user actions. If you just want them to be started or stopped, look into setting the Service Startup type via VBS.
 
Status
Not open for further replies.
Back
Top Bottom