Windows programmatically change firewall profile

409 Views Asked by At

for some reasons I need to change windows firewall profiles (private/public) programmatically for given adapter. It may be using command line, c++ or python. I was searching for any hint on MSDN, but it seems to me that the only things I can change, are how firewall acts when some profile is running.

I imagine something like:

#include "Netfw.h"

int main()
{
    NET_FW_PROFILE* fwProfile = get_FirewallProfile("Local Area Connection");
    if(fwProfile.setProfile(NET_FW_PROFILE2_PUBLIc))
        return 0;

    return 1;
}

Sorry if this pseudoexample is too dumb, I'm not much familiar with windows C++ programming.

1

There are 1 best solutions below

0
initialed85 On

I'm afraid I don't have a Windows machine at my disposal, but this may get you in the ballpark:

How to use "netsh advfirewall" etc...

Example 5 seems to have some information about your question.