Windows防火墙:使用批处理更改日志文件位置


1

我正在寻找一种方法,可以使用命令行更改防火墙的日志文件位置,最终将其放在批处理文件中。

我知道可以在“高级防火墙设置”中从UI启用和配置日志,但我无法找到是否可以从命令行执行此操作。

MSDN文档只是从UI解释它,我可以收集的所有信息也解释了如何从UI进行操作。


如果您可以升级到更新的PowerShell版本,您将能够以这种方式管理防火墙。Set-NetFirewallProfile
Spokey 2016年

感谢您对@Spokey的帮助,但遗憾的是我无法访问PowerShell,因为它实际上是Windows Embedded Standard 7,并且设备上尚未安装PowerShell组件。
Martin Verjans 2016年

Answers:


1

我终于设法找到了Microsoft的文档。

使用时netsh advfirewall,可以修改日志记录设置。

以下是文章的链接:如何使用“netsh advfirewall firewall”上下文而不是“netsh firewall”上下文来控制Windows Server 2008和Windows Vista中的Windows防火墙行为

您需要向下滚动到示例5:设置记录。以下是要输入的命令:

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
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.