Kaseya Community

Script to disable Windows Firewall

  • New to Kaseya and to Scripting and was wondering if anyone had a script to disable the Windows XP Firewall.

    Thanks
    Chris

    Legacy Forum Name: Script to disable Windows Firewall,
    Legacy Posted By Username: ModernTechIT
  • This is a short script I wrote to disable the Windows Firewall and the Security Center service. It does require a reboot, you can add a force reboot at the end of the script if you like.

    Script Name: Security Center & Windows Firewall - Disable
    Script Description: ***REQUIRES REBOOT***
    Turns off Windows Firewall and Disables Security Center service from starting via Registry.

    Created by:
    Charles Surrett @ CNWI
    5/22/08


    IF Service is Running
    Parameter 1 : SharedAccess
    THEN
    Execute Shell Command
    Parameter 1 : netsh firewall set opmode disable
    Parameter 2 : 0
    OS Type : 0
    Set Registry Value
    Parameter 1 : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wscsvc\Start
    Parameter 2 : 00000004
    Parameter 3 : REG_DWORD
    OS Type : 0
    ELSE

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: cnwicsurrett
  • You can also create an ELSE statement to log that Windows Firewall is already disabled.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: cnwicsurrett
  • This is a small script i use to turn it off immediately and then disable the service.

    Script Name: AL-XP SP2 Firewall - OFF
    Script Description: This script will immediately turn the Windows XP SP2 Firewall Off. (No reboot required)

    IF True
    THEN
    Execute Shell Command
    Parameter 1 : net stop sharedaccess
    Parameter 2 : 1
    OS Type : 8
    Set Registry Value
    Parameter 1 : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Start
    Parameter 2 : 4
    Parameter 3 : REG_DWORD
    OS Type : 8
    ELSE

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: RatTrap
  • It's good to have this script. Hw bout we reverce the process. Can we turn it on using script?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: tesvin
  • Nice work! Nice not having to reboot to enable/disable the firewall.
    The script to enable the firewall is:


    Script Name: Enable XPSP2 Firewall
    Script Description: This script will immediately turn the Windows XP SP2 Firewall On. (No reboot required)

    IF True
    THEN
    Set Registry Value
    Parameter 1 : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Start
    Parameter 2 : 2
    Parameter 3 : REG_DWORD
    OS Type : 8
    Execute Shell Command
    Parameter 1 : net start sharedaccess
    Parameter 2 : 1
    OS Type : 8
    ELSE

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: eddy@dgs.com.au
  • Eddy,

    To use your script works, i need to off the firewall using the same script with diff parameter like RatTrap showed b4. Your script won't work if i disable it manually. Why huh?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: tesvin
  • This is what i use....

    Script Name: Disable Windows Firewall
    Script Description: Disable Windows Firewall (netsh firewall set opmode disable)

    IF True
    THEN
    Execute Shell Command
    Parameter 1 : netsh firewall set opmode disable
    Parameter 2 : 0
    OS Type : 0
    ELSE

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Munnster
  • To enable the firewall back...

    Script Name: Enable Windows Firewall copy
    Script Description: Enable Windows Firewall (netsh firewall set opmode enable)

    IF True
    THEN
    Execute Shell Command
    Parameter 1 : netsh firewall set opmode enable
    Parameter 2 : 0
    OS Type : 0
    ELSE

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Munnster
  • This one enables file sharing through windows firewall...

    Script Name: Windows Firewall - Enable File Sharing
    Script Description: Enables file sharing exception in windows firewall

    IF True
    THEN
    Execute Shell Command
    Parameter 1 : netsh firewall set service type = FILEANDPRINT mode = ENABLE
    Parameter 2 : 0
    OS Type : 0
    ELSE

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Munnster
  • @Munnster

    These didn't work for me granted windows firewall is auto set to enabled via group policy and I haven't got the chance to try it on a non group polict machine as of yet

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: YLindsay