Create a firewall rule using powershell

mrhollyster :

I am trying to create a firewall rule for java in powershell. The problem is that even if I create exactly the same rule as windows creates automatically, it simply ignores it (I create the rule, then I start our custom company application - just normally from desktop - which uses java and then the firewall window asking about allowing or blocking traffic appears - I mean the Windows Security Alert window, which appears when you run an application for the first time). Is it somehow possible? I just want to automatically allow java through firewall in my script without the need of user interaction. This is the command I'm using:

New-NetFirewallRule -DisplayName "Java(TM) Platform SE binary" -Direction Inbound -Program "C:\program files (x86)\common files\oracle\java\javapath_target_49433390\java.exe" -Action Allow
JPBlanc :

I've got the same trouble using netsh.exe when I forgot enable=yes

netsh advfirewall firewall add rule name="app name" dir=in action=allow program="Full path of .exe" enable=yes

So can you try to add -Enabled True to your command line.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=4342&siteId=1