While Windows Firewall service is disabled trying to apply this ↓ command

netsh advfirewall firewall add rule name="My App (HTTP-In)" dir=in action=allow protocol=TCP localport=1234 remoteip=localsubnet program=SYSTEM

causes this error:

An error occurred while attempting to contact the  Windows Firewall service. Make sure that the service is running and try your request again.

I know that you can add rules directly through Registry Editor by adding values to this ↓ key, but I would like to omit this way.


The question is: Is there another way to add firewall rules while Windows Firewall service is disabled?


Nope, because the Firewall service isn't running. Enable it, add the rules with netsh, and then disable it when done. Or add via the registry as you have suggested.

Either way should be pretty painless to repeat once you've scripted it once.

  • Agreed. If OP needs to test it with minimal disruption to a service, I would say test the script on another PC first. – Christopher Hostage May 16 '18 at 17:24
  • As stated in TechNet Magazine 2007, it's better to only use the service instead of registry for editing firewall rules. So I will stick to Start/Edit/Stop method. – Corio May 16 '18 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.