Hi ,

I have wrote a vbscript to check windows firewall status. But this is not seems to be working.when I run script it shows issue with line 23. But I cant understand what need to be changed and also is this enough to check all other firewall profile as well ? can any one help here please ?

Option Explicit

'Create Shell object
Dim objShell
set objShell = CreateObject("Shell.Application")

'Declare Firewall variables
Dim fwMgr
Dim profile

' Firewall objects have to be created after making sure
' the service is running. If the service isn't running,
' the script will fail.

' Create the firewall manager object.
Set fwMgr = CreateObject("HNetCfg.FwMgr")

' Get the current profile for the local firewall policy.
Set profile = fwMgr.LocalPolicy.CurrentProfile

'Verify that the Firewall is enabled. If it is, then disable it.
If profile.FirewallEnabled = TRUE  Then
    profile.FirewallEnabled =FALSE
End If
WScript.Echo("tr_FirewallEnabled: " & profile.FirewallEnabled)

0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answers

0

We'll guess what the "issue" is with line 23, shall we?

I suspect you're getting "Object doesn't support this action" which, in true Microsoft style, doesn't tell you *exactly* what the problem is, namely that the account you're using doesn't have sufficient privileges to enable the firewall.

Answered 04/26/2016 by: VBScab
Red Belt

Please log in to comment
0
You try to disable the Firewall in Line 23

profile.FirewallEnabled = FALSE

But maybe the change is not allowed by this user or prohibited by a group policy. This script isn´t working in my domain environment, but will disable the firewall on a standalone machine.
Answered 04/26/2016 by: aragorn.2003
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity