Hi all,
I am working through a scripting situation inwhich I need to create an array which has values that match the Win32_Service names of various services I am trying to shut off.
My first big obsticle is the proper syntactical concatenation mess that I currently have for a query into WMI.
Can anyone offer any insight into what it is that im missing?
Thanks!
Steven
I am working through a scripting situation inwhich I need to create an array which has values that match the Win32_Service names of various services I am trying to shut off.
My first big obsticle is the proper syntactical concatenation mess that I currently have for a query into WMI.
Can anyone offer any insight into what it is that im missing?
Thanks!
Steven
Option Explicit
'On Error Resume Next
Dim StrComputer, strService
Dim objWMIService, objService
Dim colServiceList
Dim errReturnCode
dim svcFW, svcVPN, svcWWifi, svcSUS, svcDWMRCS
Dim arrServicesTBTO(4)
svcFW = "Service0"
svcVPN = "service1"
svcWWifi = "Service2"
svcSUS = "Service3"
svcDWMRCS = "Service4"
arrServicesTBTO(0) = svcFW
arrServicesTBTO(1) = svcVPN
arrServicesTBTO(2) = svcWWIFI
arrServicesTBTO(3) = svcSUS
arrServicesTBTO(4) = svcDWMRCS
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
for each strService in arrServicesTBTO
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name = "'strService' )
for each objService in colServiceList
objService.StopService
wscript.echo objService.DisplayName & " has been stopped."
Next
Next