简体   繁体   English

Netsh设置规则取决于OS语言

[英]Netsh set rule depends on OS language

I was creating a batch script to run several commands to enable winrm, changing network category and such and I got across a problem with the netsh command, specifically netsh advfirewall firewall set rule group=”Network Discovery” new enable=yes 我正在创建一个批处理脚本,以运行多个命令来启用Winrm,更改网络类别等,并且遇到了netsh命令的问题,特别是netsh advfirewall firewall set rule group=”Network Discovery” new enable=yes

After digging around and messing with UAC and registry I understood my problem: Windows language. 深入研究UAC和注册表后,我理解了我的问题:Windows语言。

So the command is setting the rule to the Network Discovery , however in my language (portuguese btw) the group is called Deteção de Rede and thus making the script unable to run across several Windows machines with different languages, making the user enable network sharing manually. 因此,该命令将规则设置为“ Network Discovery ,但是在我的语言(葡萄牙语)中,该组称为Deteção de Rede ,因此使脚本无法在使用不同语言的多台Windows计算机上运行,​​从而使用户手动启用网络共享。

My question is: Is there global way of calling the Network Discovery group? 我的问题是:是否有全局方法来呼叫Network Discovery组? or creating a new group linking to it? 或创建一个链接到它的新组?

This is my script btw: 这是我的脚本顺便说一句:

@ECHO ON
REM Run as admin
powershell.exe /c Get-NetConnectionProfile;
powershell.exe /c Set-NetConnectionProfile -NetworkCategory Private;
powershell.exe /c netsh advfirewall firewall set rule group=”Deteção de Rede” new enable=yes
cmd.exe /c winrm quickconfig -q
cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}

@ECHO Done.

Thankfully to @lit I found a way to set the rules to the group. 幸运的是,对@lit,我找到了一种为组设置规则的方法。 Used the command powershell.exe /c netsh advfirewall firewall set rule group="@FirewallAPI.dll,-32752" new enable=Yes to enable Network Sharing and powershell.exe /c netsh advfirewall firewall set rule group="@FirewallAPI.dll,-28502" new enable=Yes to enable files and print sharing (if you want to use this to target a windows machine you may want to activate them both) and now i'm able to run my ansible playbook to windows 使用命令powershell.exe /c netsh advfirewall firewall set rule group="@FirewallAPI.dll,-32752" new enable=Yes以启用网络共享,并使用powershell.exe /c netsh advfirewall firewall set rule group="@FirewallAPI.dll,-28502" new enable=Yes以启用文件和打印共享(如果您要使用它来定位Windows计算机,则可能要同时激活它们),现在我可以在Windows上运行ansible剧本了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM