博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AddFirewallPort.vbs(批量添加端口)
阅读量:6254 次
发布时间:2019-06-22

本文共 2119 字,大约阅读时间需要 7 分钟。

ON ERROR RESUME NEXT

Function AddFirewallPort(strName,iPort,iProtocol,iScope,bEnabled)

Set objFirewall = CreateObject("HNetCfg.FwMgr")

Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set objPort = CreateObject("HNetCfg.FwOpenPort")

 

objPort.Name = strName '名称

objPort.Port = iPort '端口号

objPort.Protocol = iProtocol 'TCP--> 6,UDP-->17

objPort.Scope = iScope '范围all-->0 ,仅我的子网-->1

objPort.Enabled = bEnabled '是否开启True or False

 

Set colPorts = objPolicy.GloballyOpenPorts

errReturn = colPorts.Add(objPort)

End Function

 

ON ERROR RESUME NEXT

Function AddFirewallPort(strName,iPort,iProtocol,iScope,bEnabled)

Set objFirewall = CreateObject("HNetCfg.FwMgr")

Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set objPort = CreateObject("HNetCfg.FwOpenPort")

 

objPort.Name = strName '名称

objPort.Port = iPort '端口号

objPort.Protocol = iProtocol 'TCP--> 6,UDP-->17

objPort.Scope = iScope '范围all-->0 ,仅我的子网-->1

objPort.Enabled = bEnabled '是否开启True or False

 

Set colPorts = objPolicy.GloballyOpenPorts

errReturn = colPorts.Add(objPort)

End Function

 

AddFirewallPort "MSDTC5000", 5000, 6, 0, True

AddFirewallPort "MSDTC5001", 5001, 6, 0, True

AddFirewallPort "MSDTC5002", 5002, 6, 0, True

AddFirewallPort "MSDTC5003", 5003, 6, 0, True

AddFirewallPort "MSDTC5004", 5004, 6, 0, True

AddFirewallPort "MSDTC5005", 5005, 6, 0, True

AddFirewallPort "MSDTC5006", 5006, 6, 0, True

AddFirewallPort "MSDTC5007", 5007, 6, 0, True

AddFirewallPort "MSDTC5008", 5008, 6, 0, True

AddFirewallPort "MSDTC5009", 5009, 6, 0, True

AddFirewallPort "MSDTC5010", 5010, 6, 0, True

AddFirewallPort "MSDTC5011", 5011, 6, 0, True

AddFirewallPort "MSDTC5012", 5012, 6, 0, True

AddFirewallPort "MSDTC5013", 5013, 6, 0, True

AddFirewallPort "MSDTC5014", 5014, 6, 0, True

AddFirewallPort "MSDTC5015", 5015, 6, 0, True

AddFirewallPort "MSDTC5016", 5016, 6, 0, True

AddFirewallPort "MSDTC5017", 5017, 6, 0, True

AddFirewallPort "MSDTC5018", 5018, 6, 0, True

AddFirewallPort "MSDTC5019", 5019, 6, 0, True

AddFirewallPort "MSDTC5020", 5020, 6, 0, True

posted on
2008-03-05 17:28 阅读(
...) 评论(
...)

转载于:https://www.cnblogs.com/cuitao/archive/2008/03/05/1092228.html

你可能感兴趣的文章
Siege——多线程编程最佳实例
查看>>
c# 生成 验证码
查看>>
SQL Server 触发器
查看>>
何为SLAM
查看>>
[工具]infolite-chrome插件css插件
查看>>
javascript 深拷贝
查看>>
【代码小记】无
查看>>
【知识点】Java机密
查看>>
BarTender 2016表单中的“秤显示”控件
查看>>
全面理解javascript的caller,callee,call,apply概念[转载]
查看>>
Jquery 下拉框取值
查看>>
IDEA中使用Maven创建Java Web项目
查看>>
2017.12.25
查看>>
react--1.创建项目
查看>>
11月20日学习内容整理:jquery插件
查看>>
预科班第四次考核总结
查看>>
html
查看>>
数据分析师到底在做什么?
查看>>
pt-heartbeat工具监控MySQL复制延迟
查看>>
指尖下的js —— 多触式web前端开发之三:处理复杂手势(转)
查看>>