Change Windows Firewall From Command Line or Batch File


I have a set of scripts I run when I prep a computer for deployment.  At specific points applications require that the windows firewall be turned off in order to install correctly.  This is namely ACT! and imagine time.  They use a bunch of odd ports during install, so their documentation tells you to just turn off the firewall. Well here is what I found with a little research.  From run or in a batch file there is a simple netsh command to disable the firewall and one to again enable it.

For imagine time my install script looks like this

netsh firewall set opmode disable
g:\Imagine_time\IT_SETUP.exe /q /p
netsh firewall set opmode enable

 
Effectively this will turn off the firewall, install the software silently from a share, and then enable the firewall again after install. I found something interesting with this in regards to kaseya too.  Sometimes VNC can’t get through the firewall because it has defaulted or something went wrong.  It turns out that if you run this as “system” you can actually disable the firewall remotely in many cases.  This has been a very helpful script for when a computer shows ‘connectable’ but it just times out when attempting connection.

Script Name: Win Firewall Off

Script Description: Turns off windows firewall

IF True 

THEN

   Execute Shell Command

     Parameter 1 : netsh firewall set opmode disable

     Parameter 2 : 1

         OS Type : 0

ELSE

Additionally,  if you change enable to disable in the above script, you can enable the firewall remotely through kaseya as well.

, ,

  1. No comments yet.
(will not be published)