To configure Windows firewall from the command line
Advanced users can use the command line to configure Windows firewall. You can use the Netsh command-line tool to configure.
The Netsh commands in the following table are available for Microsoft Windows XP Service Pack 2 (SP2). Type the netsh command and the "/?" The Help for this command is displayed.
ADD
netsh firewall add allowedprogram adds the allowed program configuration to Windows Firewall
netsh firewall add portopening Adding a port configuration to Windows Firewall
Delete
netsh firewall delete allowedprogram remove allowed program configuration from Windows Firewall
netsh firewall delete portopening remove port configuration from Windows Firewall
Reset
netsh firewall reset resets the Windows firewall configuration to the default configuration
Set
netsh firewall set allowedprogram editing the Allow program configuration in Windows Firewall
netsh firewall set icmpsettings edit ICMP configuration in Windows Firewall
netsh firewall set logging edit logging configuration in Windows Firewall
netsh firewall set notifications edit notification configuration in Windows firewall
netsh firewall set opmode edit operation configuration in Windows Firewall
netsh firewall set portopening edit port configuration in Windows Firewall
netsh firewall set service edit Services configuration in Windows Firewall
Show
netsh firewall show allowedprogram shows the allowed program configuration in Windows Firewall
netsh firewall show config displays Windows firewall configuration
netsh firewall show currentprofile Displays the current configuration file for Windows firewall
netsh firewall show icmpsettings shows the ICMP configuration in Windows Firewall
netsh firewall show logging shows the logging configuration in Windows Firewall
netsh firewall show notifications Show notification configuration in Windows firewall
netsh firewall show opmode shows the operation configuration in Windows Firewall
netsh firewall show portopening shows the port configuration in Windows Firewall
netsh firewall show service shows the configuration of services in Windows firewall
netsh firewall show state displays the current status of Windows firewall
Attention
- Windows Firewall does not support setmachine,set online,set offline , and Dump commands, and these commands do nothing.
- The show command typically displays only locally configured settings. Group Policy settings are displayed only in the display state.
http://tcshare.org/%E4%BB%8E%E5%91%BD%E4%BB%A4%E8%A1%8C%E9%85%8D%E7%BD%AEwindows%E9%98%B2%E7%81%AB%E5%A2%99/
To configure Windows firewall from the command line