如何使用命令检查窗口的防火墙是否启用 [英] How to check window's firewall is enabled or not using commands
问题描述
我正在安装程序中使用 netsh advfirewall firewall 命令添加 Windows 防火墙规则.如果系统禁用了 Windows 防火墙,我的代码会给出错误消息.
I am adding a windows firewall rule using netsh advfirewall firewall command in a setup program. My code is giving an error message if the system has windows firewall disabled.
所以我需要在执行命令netsh advfirewall firewall add之前检查窗口的防火墙状态.即,如果防火墙被禁用,则无需添加规则.
So I need to check the window's firewall status before executing the command netsh advfirewall firewall add. ie, if firewall is disabled, no need to add the rule.
我正在使用窗口注册表值EnableFirewall"检查防火墙是否已启用.
I am checking if the firewall is enabled or not by using the window registry value "EnableFirewall".
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile
我不确定这是正确的方法.也可以有域防火墙配置文件(?).
I am not sure this is the right way. There can be domain firewall profile(?) also.
提前致谢.
推荐答案
另一种选择是使用 netsh
本身来检查防火墙是否启用.执行命令 netsh advfirewall show private|public|domain
.它将打开/关闭状态.
Another option is to use netsh
itself to check if firewall is enabled or not. Execute the command netsh advfirewall show private|public|domain
. It will give the state on/off.
这篇关于如何使用命令检查窗口的防火墙是否启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!