如何在使用install4j安装时打开Windows防火墙端口?
我找到了这个C#的解决方案,但是我无法将其移植到install4j自定义代码中:
http://www.codeproject.com/Articles/14906/Open-Windows-Firewall-During-Installation
也许有人有想法或替代方案吗?
如何在使用install4j安装时打开Windows防火墙端口?
我找到了这个C#的解决方案,但是我无法将其移植到install4j自定义代码中:
http://www.codeproject.com/Articles/14906/Open-Windows-Firewall-During-Installation
也许有人有想法或替代方案吗?
虽然这个问题问了一段时间,但我用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非常挑剔。更糟糕的是,当它无法解析您的输入时,它往往会打印出非常没有帮助和误导性的消息。所以请注意以下几点:
name="rule name"
,那么只需在命令行中执行即可。对于install4j,参数应该是name=rule name
不带引号。谢谢,我找到了一个类似的解决方案,我只是创建了一个名为“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