Board logo

标题: VBS通过WMI启用“TCP/IP 筛选” 并设置端口号 [打印本页]

作者: youxi01    时间: 2008-2-13 17:00     标题: VBS通过WMI启用“TCP/IP 筛选” 并设置端口号

程序名:      通过 WMI 启用"TCP/IP 筛选" 并设置端口号 vbs版
作者:      yongfa365  



  1. On Error Resume Next  
  2.   
  3. Const ALLOW_ALL = "0"  '允许全部   
  4. Const ALLOW_NONE = ""  '禁止全部   
  5. strComputer = "."  
  6. blnIPFilterSecurityEnabled = "False"  
  7. arrPermittedTCPPorts = Array("80", "443", "1433", "3389", "21") '要添加的端口号   
  8. arrPermittedUDPPorts = Array(ALLOW_NONE)   
  9. arrPermittedIPProtocols = Array(ALLOW_ALL)   
  10.   
  11. Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")   
  12. SpecifyFilters   
  13.   
  14. Sub SpecifyFilters   
  15.   
  16. Set colNicConfig = objWMIService.ExecQuery  ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")   
  17. For Each objNicConfig in colNicConfig   
  18.   intIPSecReturn = objNicConfig.EnableIPSec(arrPermittedTCPPorts,    arrPermittedUDPPorts, arrPermittedIPProtocols)   
  19.   If intIPSecReturn = 0 Then  
  20.     WScript.Echo "网卡:" & objNicConfig.ServiceName & vbcrlf & """TCP/IP筛选"" 端口和协议已经启用."  
  21.   ElseIf intIPSecReturn = 1 Then  
  22.     WScript.Echo "网卡:" & objNicConfig.ServiceName & vbcrlf & """TCP/IP筛选"" 端口和协议已经启用."      & VbCrLf & "必须重新启动使更改生效."  
  23.   Else  
  24.     WScript.Echo "不通启用 网卡:" & objNicConfig.ServiceName & vbcrlf & """TCP/IP筛选"" 端口和协议."  
  25.   End If  
  26. Next  
  27.   
  28. End Sub  
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2