/build/static/layout/Breadcrumb_cap_w.png

Vbscript to check windows firewall status

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

Answers (2)

Posted by: anonymous_9363 8 years ago
Red Belt
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.

Posted by: aragorn.2003 8 years ago
Red Belt
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.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ