To Allow App through Windows Defender Firewall in Command Prompt

时间:2020-05-28
本文章向大家介绍To Allow App through Windows Defender Firewall in Command Prompt,主要包括To Allow App through Windows Defender Firewall in Command Prompt使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

https://www.tenforums.com/tutorials/70903-add-remove-allowed-apps-through-windows-firewall-windows-10-a.html

To Allow App through Windows Defender Firewall in Command Prompt

To see more usage options for the Netsh AdvFirewall Firewall add rule command, see: Netsh AdvFirewall Firewall Commands - Microsoft Docs

 1. Open an elevated command prompt.

2. Enter the command below you want to use into the elevated command prompt, and press Enter. (see screenshot below)


(Allow app)
netsh advfirewall firewall add rule name="app name" dir=in action=allow program="Full path of .exe" enable=yes

OR

(Block app)
netsh advfirewall firewall add rule name="app name" dir=in action=block program="Full path of .exe" enable=yes

   Note
Substitute app name in the command above with the actual name of the app (ex: "Google Chrome").

Substitute Full path of .exe in the command above with the actual full path to the .exe file (ex: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe") of the app.

For example:
Code:
netsh advfirewall firewall add rule name="Google Chrome" dir=in action=allow program="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" enable=yes


3. When finished, you can close the elevated command prompt if you like.

To Remove Allowed App in Command Prompt

To see more usage options for the Netsh AdvFirewall Firewall delete rule command, see: Netsh AdvFirewall Firewall Commands - Microsoft Docs

Open an elevated command prompt.

2. Enter the command below into the elevated command prompt, and press Enter. (see screenshot below)


netsh advfirewall firewall show rule name=all >"%UserProfile%\Desktop\WindowsFirewallRules.txt"


3. You will now have a WindowsFirewallRules.txt file saved to your desktop containing a list of all Windows Firewall rules.

4. Open the WindowsFirewallRules.txt file, and make note of the Rule Name (ex: "Google Chrome") of the app you want to remove all rules for. (see screenshot below)



5. Enter the command below into the elevated command prompt, and press Enter. (see screenshot below)


netsh advfirewall firewall Delete rule name="Rule Name"

   Note
Substitute Rule Name in the command above with the actual rule name (ex: "Google Chrome") you want to remove from step 4 above.

For example: netsh advfirewall firewall Delete rule name="Google Chrome"


6. When finished, you can close the elevated command prompt if you like.

原文地址:https://www.cnblogs.com/chucklu/p/12980246.html