AddFirewallPort.vbs(批量添加端口)

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 Neo Devin 阅读( ...) 评论( ...) 编辑 收藏

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

评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符 “速评一下”
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页