Click here to Skip to main content
15,887,952 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys ,
This is regarding firewall exceptions list , I have an application which during installtion I want it to add in the list of exceptions in the windows firewall list and that too in public mode .How can I achieve that ?
This is how we add the application in exceptions list during installation .
This is a script in InstallShield Wizard
if(AskYesNo(szFireWallException, YES) = YES)
then
szAppPath = TARGETDIR ^ "\\Exception.exe";
LaunchAppAndWait(szAppPath, "ABC.exe ABC", WAIT);
DeleteFile(szAppPath);
endif;
But this script does not add the program in the public mode .

Thanks
Posted

1 solution

INetFwRule firewallRule =  ( INetFwRule ) Activator . CreateInstance ( Type . GetTypeFromProgID ( "HNetCfg.FWRule" )); 
        firewallRule . Action  = NET_FW_ACTION_ . NET_FW_ACTION_ALLOW ; 
        firewallRule . Description  =  "Allow notepad" ; 
        firewallRule . ApplicationName  =  @"C:\Windows\notepad.exe" ; 
        firewallRule . Enabled  =  true ; 
        firewallRule . InterfaceTypes  =  "All" ; 
        firewallRule . Name  =  "Notepad" ;

        INetFwPolicy2 firewallPolicy =  ( INetFwPolicy2 ) Activator . CreateInstance ( 
            Type . GetTypeFromProgID ( "HNetCfg.FwPolicy2" )); 
        firewallPolicy . Rules . Add ( firewallRule );
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900