Windows Firewall command Explanation (program enable command line execution)

Source: Internet
Author: User

Set 9998 name = ssssssssssssssssssssssss Mode = ENABLE Scope = SUBNET profile =in1433 Remo Teip = LocalSubnet profile = DOMAIN

Old command for Win7 versions < include win7>

Example 1: enable a process sequence

Old command

New command

netsh firewall add allowedprogram C:\MyApp\MyApp.exe "My application" ENABLE

netsh advfirewall firewall add rule name= "My application" Dir=in action=allow program= "C:\MyApp\MyApp.exe" Enable=yes

netsh firewall add allowedprogram program=c:\myapp\myapp.exe name= "My application" mode=enable scope=custom addresses= 157.60.0.1,172.16.0.0/16,localsubnet Profile=domain

netsh advfirewall firewall add rule name= "My application" Dir=in action=allow program= "C:\MyApp\MyApp.exe" Enable=yes rem Oteip=157.60.0.1,172.16.0.0/16,localsubnet Profile=domain

netsh firewall add allowedprogram program=c:\myapp\myapp.exe name= "My application" mode=enable scope=custom addresses= 157.60.0.1,172.16.0.0/16,localsubnet Profile=all

Run the following commands:

netsh advfirewall firewall add rule name= "My application" Dir=in action=allow program= "C:\MyApp\MyApp.exe" Enable=yes rem Oteip=157.60.0.1,172.16.0.0/16,localsubnet Profile=domain

netsh advfirewall firewall add rule name= "My application" Dir=in action=allow program= "C:\MyApp\MyApp.exe" Enable=yes rem Oteip=157.60.0.1,172.16.0.0/16,localsubnet profile=private

Example 2: Enable ports

Old command

New command

netsh firewall add portopening TCP "Open Port 80"

netsh advfirewall firewall add rule name= "Open Port" Dir=in action=allow protocol=tcp localport=80

Example 3: Remove an enabled program or port

Old command

New command

netsh firewall delete allowedprogram C:\MyApp\MyApp.exe

netsh advfirewall firewall delete rule name= Rule name program= "C:\MyApp\MyApp.exe"

Delete portopening protocol=udp port=500

netsh advfirewall firewall delete rule name= Rule name protocol=udp localport=500

Example 4:icmp Configuration

Old command

New command

netsh firewall set icmpsetting 8

netsh advfirewall firewall add rule name= "ICMP allow incoming V4 echo request" Protocol=icmpv4:8,any Dir=in Action=allow

netsh firewall set icmpsetting type=all mode=enable

netsh advfirewall firewall add rule name= "all ICMP V4" Protocol=icmpv4:any,any dir=in Action=allow

Example 5: Setting up Logs

Old command

New command

netsh firewall set logging%systemroot%\system32\logfiles\firewall\pfirewall.log 4096 enable enable

Run the following commands:

netsh advfirewall set currentprofile logging filename%systemroot%\system32\logfiles\firewall\pfirewall.log

netsh advfirewall set currentprofile logging maxfilesize 4096
netsh advfirewall set currentprofile logging droppedconnections enable

netsh advfirewall set currentprofile logging allowedconnections enable

Example 6: Start the firewall

Old command

New command

netsh firewall set opmode ENABLE

netsh advfirewall set currentprofile state on

netsh firewall set opmode mode=enable exceptions=enable

Run the following commands:

Netsh Advfirewall set currentprofile state on

netsh advfirewall set currentprofile firewallpolicy blockinboundalways,allowoutbound

netsh firewall set opmode mode=enable exceptions=disable Profile=domain

Run the following commands:

Netsh Advfirewall set domainprofile state on

netsh advfirewall set domainprofile firewallpolicy blockinbound,allowoutbound

netsh firewall set opmode mode=enable profile =all

Run the following commands:

netsh advfirewall set domainprofile state on

netsh advfirewall set privateprofile state on

For more information, run the following command:

netsh advfirewall set currentprofile?

Example 7: Restore the default firewall policy

Old command

New command

netsh firewall reset

netsh advfirewall reset

To view more information, run the following command

netsh advfirewall reset?

Example 8: enable a specific service

Old command

New command

netsh firewall set service fileandprint

netsh advfirewall firewall set rule group= "File and Printer sharing" new Enable=yes

netsh firewall set service remotedesktop enable

netsh advfirewall firewall set rule group= "Remote Desktop" new Enable=yes

netsh firewall set service remotedesktop enable Profile=all

Run the following commands:

netsh advfirewall firewall set rule group= "Remote Desktop" new Enable=yes Profile=domain

netsh advfirewall firewall set rule group= "Remote Desktop" new Enable=yes profile=private

Windows Firewall command Explanation (program enable command line execution)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.