Question

I am using this code to add the software "example.exe" 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 do the "in|out" part in one only 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
Était-ce utile?

La solution

You could do this with a quicky batch file like:

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
)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top