mrhollyster
mrhollyster

Reputation: 43

Create a firewall rule using powershell

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

Upvotes: 4

Views: 3461

Answers (1)

JPBlanc
JPBlanc

Reputation: 72630

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.

Upvotes: 2

Related Questions