在安装过程中如何打开防火墙端口? [英] Howto open firewall ports during installation?

查看:68
本文介绍了在安装过程中如何打开防火墙端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用install4j安装期间如何打开Windows防火墙端口?
我为c#找到了此解决方案,但无法将其移植到install4j自定义代码:
http://www.codeproject.com/Articles/14906/Open-Windows-Firewall-安装期间

也许有人有想法或替代解决方案?

How can I open Windows Firewall ports during installation with install4j?
I found this solution for c#, but I'm unable to port it to install4j custom code:
http://www.codeproject.com/Articles/14906/Open-Windows-Firewall-During-Installation

Perhaps someone has an idea or alternate solution?

推荐答案

问了问题已经有一段时间了,但这是我如何通过install4j 5.1/6.1做到的

It's been a while since the question was asked, but here's how I did it with install4j 5.1/6.1

对于每条防火墙规则,我都使用运行可执行文件或批处理文件"具有以下参数的操作:

For every firewall rule I used the "run executable or batch file" action with the following parameters:

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

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

参数:取决于我要使用 netsh 语法.

Arguments: depending on the rule I wanted to create using the netsh syntax.

例如: advfirewall;防火墙添加;规则;name = $ {compiler:sys.shortName} UDP IN;dir = in;动作=允许;service = $ {compiler:sys.shortName};localip = any;remoteip = any;localport = any;remoteport = any;protocol = udp;interfacetype = any;安全性=不需要;边缘=否;profile = any;enable =是

或者,在编辑对话框中:

or, from the edit dialog:

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在接收到的参数方面很挑剔.更糟糕的是,当它无法解析您的输入时,它往往会打印出非常无用和误导性的消息.因此请注意以下几点:

netsh is finicky with regard to the parameters it receives. And even worse, it tends to print very unhelpful and misleading messages when it fails to parse your input. So note the following:

  1. 将每个netsh命令作为单独的参数传递.在属性表中,使用分号将它们分开.在编辑对话框中,用换行符分隔.
  2. 请勿在参数中使用引号.如果Microsoft文档告诉您指定像这样的规则名称: name ="rule name" ,则只能在命令行中进行操作.在install4j中,参数应为 name =规则名称 不带引号.
  3. 确保您的论点中不包含任何不该包含的内容,例如不属于它们的地方的空白.netsh不喜欢这样.
  1. Pass each netsh command as a separate argument. In the property sheet separate them using semicolons. In the edit dialog separate by newlines.
  2. Don't use quotes in your arguments. If the Microsoft documentation tells you to specify a rule name like this: name="rule name", then do that in the command line only. From install4j, the argument should be name=rule name without quotes.
  3. Make sure that your arguments don't contain anything they shouldn't, like white spaces in places where they don't belong. netsh doesn't like that.

这篇关于在安装过程中如何打开防火墙端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆