Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
objPolicy.FirewallEnabled = FALSE

This script does not work in Vista/2008 and Windows 7 anymore. Even with elevation.

The error box is shown "a program or firewall is not compatible with this version of windows"

share|improve this question

For a simple command line \ batch file:

netsh firewall set opmode disable

Or with PowerShell:

$firewall = New-Object -com HNetCfg.FwMgr
$firewall.LocalPolicy.CurrentProfile.FirewallEnabled = $false

Both work fine under Windows Vista. If you are still having issues then I'd dig further to ensure that you have the right permissions and that you are using core windows components to execute the script. I have a parallel install of PowerShell (used by the VMWare VI Toolkit) that throws exactly the same security exception you list above when I try to use it to disable the firewall but for the basic Powershell v1.0 installation it works fine.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.