我知道下面的cmd可以启用文件和打印共享防火墙规则:
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yes
但它打开所有configuration文件的文件和打印共享。
我只想启用它的私人资料,即当Windows PC /笔记本电脑连接到家庭或工作networking。 我特别试图避免将其连接到公共networking的笔记本电脑。 理想情况下,networking发现应closures公共networking。
我试过了
netsh advfirewall firewall set rule group=”File and Printer Sharing” profile=private new enable=Yes
和“个人资料”开关被拒绝。 那么如何select性地应用防火墙规则呢?
许多thx任何input..
您正在激活一个预设的规则,我猜预设的规则有Profile=any在它。
先试试这个:
netsh advfirewall firewall set rule group="File and Printer Sharing" new profile=private
netsh advfirewall firewall set rule name="File and Printer Sharing (SMB-In)" dir=in profile=public|private|domain new enable=Yes|No
要一次设置三个configuration文件,请使用:
netsh advfirewall firewall set rule name="File and Printer Sharing (SMB-In)" dir=in new enable=Yes
规则名称必须使用您的本地语言进行更改,例如:
netsh advfirewall firewall set rule name="檔案及印表機共用 (SMB-In)" dir=in profile=private new enable=Yes
不要忘记以pipe理员身份运行。
围绕这个问题,在使用本地语言名称不起作用的情况下,很less出现这种情况。 波兰语Udostępnianie plików i drukarek (SMB — ruch przychodzący) = File and Printer Sharing (SMB-In) 。 我相信这与UTF-8在netsh中的处理有关,因为有报道说使用netsh连接到UTF指定的wifinetworking有时不起作用。
在这些情况下,使用PowerShell的Set-NetFirewallRule和与语言无关的“Name”参数(在这种情况下是FPS-SMB-In-TCP )。 使用Get-NetFirewallRule命令为您的规则获取所有正确的名称。
在提升的powershell提示符下input:
Set-NetFirewallRule -DisplayGroup "File And Printer Sharing" -Enabled True -Profile Private
它在Windows 10 1703上为我工作