如何通过批处理文件在Windows防火墙上打开端口 [英] How to open ports on Windows firewall through batch file

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

问题描述

批处理文件中是否可以通过批处理文件在Windows上打开特定端口?最好让安装程序为我们的服务器应用程序执行此操作,而不是让用户手动执行此操作.

Is there any way within a batch file to open up specific ports on Windows through a batch file? It would be nice to have the installer do this for our server application rather than having the user manually do it.

推荐答案

使用

Use netsh.exe. A very simple batch file that takes a port argument:

@echo off
rem -- open port (first argument passed to batch script)
netsh advfirewall firewall add rule name="Open Port %1" dir=in action=allow protocol=TCP localport=%1 remoteip=10.15.97.0/24,10.17.0.0/16

这篇关于如何通过批处理文件在Windows防火墙上打开端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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