高级防火墙异常(任何方向)



我正在使用此代码将软件" example.exe"添加到异常列表:

netsh advfirewall firewall add rule action=allow profile=any protocol=any enable=yes direction=in name=example_in program = "C:\Program Files\example.exe" > NUL
netsh advfirewall firewall add rule action=allow profile=any protocol=any enable=yes direction=out name=example_out program = "C:\Program Files\example.exe" > NUL

我只能在仅一行中执行" in | out"部分?

我的意思是:

netsh advfirewall firewall add rule action=allow profile=any protocol=any enable=yes direction=any name=example_in program = "C:\Program Files\example.exe" > NUL

您可以使用快速批处理文件进行此操作:

for %%x in (in out) do (
    netsh advfirewall firewall add rule action=allow profile=any protocol=any enable=yes direction=%%x name=example_%%x program = "C:\Program Files\example.exe" > NUL
)

相关内容

最新更新