Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add NSIS firewall exception for both private and public profiles

I want to add my application to windows firewall excpetion list. I am using NSIS Simple Firewall Plugin and doing following.

SimpleFC::AddApplication "${PRODUCT_NAME}" "$INSTDIR/${PRODUCT_NAME}.exe" 3 2 "" 1
Pop $0 ; return error(1)/success(0)

My app is getting added successfully to the firewall exception list but the problem is I want to add the exception for both public and private network profiles like below: enter image description here

But there is no option for same in the mentioned plugin, and the currently active profile (either public or private) gets selected by default.

I have explored other nsis firewall plugins but none of them has this feature. Can someone tell me the way forward? I may consider writing a custom plugin for the same.

But I am just wondering, is it achievabe or is there any fundamental blocker?

Although, you can always select both checkboxes manually.

like image 312
foobar Avatar asked Dec 31 '25 05:12

foobar


1 Answers

I was never able to get any of the NSIS Firewall plugins to work correctly for me. I ended up simply shelling out to netsh on my target system:

In the install section:

ExecWait 'netsh advfirewall firewall add rule name=MyProg dir=in action=allow program="$INSTDIR\MyProg.exe" enable=yes profile=public,private'

In the uninstall section:

ExecWait 'netsh advfirewall firewall delete rule name=MyProg'
like image 107
Michael Kohne Avatar answered Jan 06 '26 06:01

Michael Kohne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!