如何在防火墙的例外中设置应用程序 [英] How to set an application in exceptions in firewall
问题描述
Hello Guys,
这是关于防火墙例外列表,我有一个应用程序,在安装期间我希望它添加到Windows防火墙列表中的例外列表中,以及在公共模式下也是如此。我怎样才能做到这一点?
这是我们在安装过程中在例外列表中添加应用程序的方式。
这是InstallShield向导中的脚本
if(AskYesNo(szFireWallException,YES)= YES)
then
szAppPath = TARGETDIR ^" \\Exception.exe" ;;
LaunchAppAndWait(szAppPath," ABC.exe ABC",WAIT);
DeleteFile(szAppPath );
endif;
但是这个脚本不会在公共模式下添加程序。
谢谢
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
推荐答案
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 );
这篇关于如何在防火墙的例外中设置应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!