Additional firewall exceptions in batch mode (in any direction)

I use this code to add example.exe software to the exception list:

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

How can I make the "in | out" part on one line?

I mean something like:

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
+4
source share
1 answer

You can do this with a fast batch file, for example:

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
)
+4
source

Source: https://habr.com/ru/post/1525853/


All Articles