Naaz,
There were a couple things wrong. You didn’t have Select * from Win32_Service terminated with a quote and there were several variations of variables dor the “computer name” (strComputer, sComputerName, etc). I also don’t know that you need to use HNetCfg.FwMgr nessisarily, I’ve disabled it in the code by remarking the two lines that change the settings– you can unremark them if you need to– but it seems to work with out it on my system
I’ve fixed the code and it is below:
Option explicit
Dim sComputer, objFirewall, ObjPolicy, objAdminSettings
Dim oService, oWMIService, colRunningServices
sComputer = “.”
Set objFirewall = CreateObject(“HNetCfg.FwMgr”)
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
‘objPolicy.FirewallEnabled = FALSE
Set objAdminSettings = objPolicy.RemoteAdminSettings
‘objAdminSettings.Enabled = TRUE
Set oWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!” & sComputer & “\root\cimv2”)
Set colRunningServices = oWMIService.ExecQuery _
(“SELECT * FROM Win32_Service”)
For Each oService in colRunningServices
Wscript.Echo oService.DisplayName & VbTab & oService.State
Next
This doesn’t help. Please see the discussion below
Discuss This Question: 2  Replies