我是 Wix安装程序的新手。我正在尝试为我的程序添加防火墙例外。
<Component Id="_VIEW.EXE" Guid="*" Transitive="yes">
<File Id="view.exe"
Name="view.exe"
KeyPath="yes"
Source="$(var.INSTALLSOURCE)\view.exe">
<fire:FirewallException Id="view_firewall_domain_tcp"
Name="View"
Protocol="tcp"
Scope="any"
IgnoreFailure="yes"
Profile="domain" />
<fire:FirewallException Id="view_firewall_domain_udp"
Name="View"
Protocol="udp"
Scope="any"
IgnoreFailure="yes"
Profile="domain" />
<fire:FirewallException Id="view_firewall_private_tcp"
Name="View"
Protocol="tcp"
Scope="any"
IgnoreFailure="yes"
Profile="private" />
<fire:FirewallException Id="view_firewall_private_udp"
Name="View"
Protocol="udp"
Scope="any"
IgnoreFailure="yes"
Profile="private" />
</File>
</Component>
在我的代码中,我添加了 4防火墙例外,并且每个例外对“个人资料”和“协议”属性都有不同的值。我的预期结果是创建了4个例外:
NAME GROUP Profile Enabled Action Override Program Local Address Remote Address Protocol Local Port Remote Port Allowed Users Allowed Computers
view Domain Yes Allow No c:\test\view.exe Any Any TCP Any Any Any Any
view Domain Yes Allow No c:\test\view.exe Any Any UDP Any Any Any Any
view Private Yes Allow No c:\test\view.exe Any Any TCP Any Any Any Any
view Private Yes Allow No c:\test\view.exe Any Any UDP Any Any Any Any
但实际结果只创建了一个例外,“Protocol”属性的值为“any”而不是“ TCP ”或“ UDP ”:< / p>
NAME GROUP Profile Enabled Action Override Program Local Address Remote Address Protocol Local Port Remote Port Allowed Users Allowed Computers
view Domain Yes Allow No c:\test\view.exe Any Any Any Any Any Any Any
我参考有关防火墙扩展的官方文档: http://wixtoolset.org/documentation/manual/v3/xsd/firewall/firewallexception.html 在文档中,我看到了一些关于“文件”属性的描述:
要授予访问所有传入端口和协议的文件的标识符。如果使用File,则不能使用Program。 如果在同一个FirewallException元素中使用File以及Port或Protocol,则该异常将无法在Windows XP和Windows Server 2003上安装.IgnoreFailure =“yes”可用于忽略导致的失败,但不会添加异常
这是否意味着如果我为程序设置防火墙规则,即使我设置“协议”,“协议”和“端口”属性也会自动为“任意”?
答案 0 :(得分:2)
现有的wix FirewallException自定义操作使用XP / Server2003 Windows防火墙API。在此API中,为特定可执行文件设置防火墙例外意味着所有端口和所有协议都将打开该异常。
供参考,XP/Server2003 firewall API interfaces。请注意,INetFwOpenPort能够获取/设置端口,而INetFwAuthorizedApplication则没有。
如果您想在程序上创建防火墙例外并明确限制端口,协议和域,您需要使用windows&#39; advanced&#39; Vista附带的防火墙API。看看这些参考文献:
Highlevel overview
Reference guide
Command-line reference guide
可悲的是,还没有人为wix实现使用这些更新API的AdvancedFirewallException扩展。也许我会开展一个kickstarter活动,看看是否有兴趣为开发提供资金; P
答案 1 :(得分:2)
尝试为每个FirewallExeption ID使用不同的名称。这对我有用:
<File Id="sample.exe"
Name="sample.exe"
Source="..\TestFrame\bin\debug\sample.exe"
Vital="yes"
KeyPath='yes'>
<fire:FirewallException Id="FirewallDomainSampleTcp"
Name="Domain Sample TCP"
Protocol="tcp"
Port="8080"
Scope="any"
IgnoreFailure="yes"
Profile="domain" />
<fire:FirewallException Id="FirewallDomainSampleUdp"
Name="Domain Sample UDP"
Protocol="udp"
Port="8080"
Scope="any"
IgnoreFailure="yes"
Profile="domain" />
<fire:FirewallException Id="FirewallPrivatSampleTcp"
Name="Private Sample TCP"
Protocol="tcp"
Port="8080"
Scope="any"
IgnoreFailure="yes"
Profile="private" />
<fire:FirewallException Id="FirewallPrivateSampleUdp"
Name="Private Sample UDP"
Protocol="udp"
Port="8080"
Scope="any"
IgnoreFailure="yes"
Profile="private" />
</File>