如何在安装过程中打开防火墙端口?

4

1
计划为install4j 6添加Windows防火墙操作,但目前该功能尚不可用。 - Ingo Kegel
太好了听到这个消息,Ingo!! - Stephane Grenier
Install4j 6仍然没有它 ;-( - Uri Shtand
2个回答

4

虽然这个问题问了一段时间,但我用install4j 5.1/6.1的方法如下:

对于每个防火墙规则,我使用“运行可执行文件或批处理文件”操作,参数如下:

可执行文件:${installer:sys.system32Dir}\netsh.exe

工作目录:${installer:sys.system32Dir}

参数:根据我想要创建的规则使用netsh语法。

例如:advfirewall; firewall; add; rule; name=${compiler:sys.shortName} UDP IN; dir=in; action=allow; service=${compiler:sys.shortName}; localip=any; remoteip=any; localport=any; remoteport=any; protocol=udp; interfacetype=any; security=notrequired; edge=no; profile=any; enable=yes

或者,在编辑对话框中:

advfirewall
firewall
add
rule
name=${compiler:sys.shortName} UDP IN
dir=in
action=allow
service=${compiler:sys.shortName}
localip=any
remoteip=any
localport=any
remoteport=any
protocol=udp
interfacetype=any
security=notrequired
edge=no
profile=any
enable=yes

建议:

关于参数,netsh非常挑剔。更糟糕的是,当它无法解析您的输入时,它往往会打印出非常没有帮助和误导性的消息。所以请注意以下几点:

  1. 将每个netsh命令作为单独的参数传递。在属性选项卡中使用分号进行分隔,在编辑对话框中使用换行符进行分隔。
  2. 不要在参数中使用引号。如果Microsoft文档告诉您要像这样指定规则名称:name="rule name",那么只需在命令行中执行即可。对于install4j,参数应该是name=rule name 不带引号
  3. 确保您的参数不包含任何不应该有的内容,例如不应该存在的空格。netsh不喜欢这样的情况。

谢谢,我找到了类似的解决方案,我只是创建了一个“firewall.cmd”文件,并编写了一些规则,让它在安装过程中由install4j执行。 - Schlocke

1

谢谢,我找到了一个类似的解决方案,我只是创建了一个名为“firewall.cmd”的文件,在安装过程中让它从install4j运行。

“firewall.cmd”文件内容:

netsh.exe advfirewall firewall delete rule name="QOMET-IN"
netsh.exe advfirewall firewall delete rule name="QOMET-OUT"
netsh.exe advfirewall firewall add rule name="QOMET-IN" protocol=TCP dir=in localport=3050,29418-29430,14416 security=notrequired action=allow profile=any enable=yes
netsh.exe advfirewall firewall add rule name="QOMET-OUT" protocol=TCP dir=out remoteport=3050,29418-29430,14416,20,21,25,587,80 security=notrequired action=allow profile=any enable=yes

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接