I got the following script from Microsoft Technet. I want to modify it so that instead of having to enter the service name into the script, the user can specify the service. In other words, how do I replace 'DbService' with a variable?
I've tried ...Where Name = '" & Variable & "'" & chr(34))
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2"
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name = 'DbService'"
For Each objService in colListOfServices
objService.StopService()
objService.Delete()
Next
I've tried ...Where Name = '" & Variable & "'" & chr(34))
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2"
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name = 'DbService'"
For Each objService in colListOfServices
objService.StopService()
objService.Delete()
Next