2

I want to add a program to windows firewall. I have done that successfuly using this code:

            INetFwAuthorizedApplication fwApp = Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwAuthorizedApplication")) as INetFwAuthorizedApplication;
            fwApp.Name = "Description";
            fwApp.Enabled = true;
            fwApp.ProcessImageFileName = applicationPath;
            fwApp.Scope = NET_FW_SCOPE_.NET_FW_SCOPE_ALL;
            fwApp.IpVersion = NET_FW_IP_VERSION_.NET_FW_IP_VERSION_ANY;
            INetFwMgr fwMgr = Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwMgr")) as INetFwMgr;
            fwMgr.LocalPolicy.CurrentProfile.AuthorizedApplications.Add(fwApp);

But, the program is added only to the private Network profile. How do I add it to all profiles (private,public,domain) ?

subirshan
  • 323
  • 2
  • 7
  • 20
  • 1
    Might be relevant: http://stackoverflow.com/questions/15409790/adding-an-application-firewall-rule-to-both-private-and-public-networks-via-win7 – sab669 Mar 09 '15 at 20:40
  • I have seen this post but the problem is that adding it as a rule, marks the "delete" button inside the windows firewall as unavailable. Using my code it doesn't to that, so I'm trying to find a workaround using my code. But thanks. – subirshan Mar 09 '15 at 20:50

0 Answers0