Ask a question »

Enabling/Disabling the firewall using command line

February 2016

You might need to switch off the firewall temporarily. To quickly disable or enable the Windows firewall during network connectivity testing, or when working on other troubleshooting tasks, use the Netsh.exe command-line on Windows XP. Configure the firewall from the command prompt by implementing the Netsh command.

With the command line

Under Windows XP SP2, it is possible to enable or disable the firewall with the following command lines.

First open the command prompt: (Windows + R keys) and type : cmd

Validate with the Enter key.

With a.BAT file

It is also possible to create a batch file (with extension. Bat) incorporating one of these command to enable or disable the firewall by simply double-clicking.

You can create a batch file to enable or disable the firewall by double-clicking on Notepad and inserting one of two lines above, then saving the file with the .bat extension (ex: Activatefirewall.BAT).

To go further you can create two files on the desktop, to enable and disable the firewall:
  • Click on Start/All Programs/Accessories/Notepad (or Start/Run/notepad/[OK])
  • Add the command:
    • netsh firewall set opmode disable
  • Click on File/Save As
  • In "File name" write "Disablefirewall.BAT"
  • Save directly on your desktop
  • Double-click this file to disable the firewall in Windows XP
  • Repeat the above operation, but now using the command
    • netsh firewall set opmode enable
  • In "File name" write "Activatefirewall.BAT"
  • Save directly on your desktop
  • Double-click this file to activate the firewall in Windows XP

Learn more: Enabling or disabling the firewall of XP
For unlimited offline reading, you can download this article for free in PDF format:

See also

In the same category

Original article published by Jeff. Translated by netty5. - Latest update by Jeff
This document entitled « Enabling/Disabling the firewall using command line » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.