程序名: 通过 WMI 启用"TCP/IP 筛选" 并设置端口号 vbs版
作者: yongfa365
- On Error Resume Next
-
- Const ALLOW_ALL = "0" '允许全部
- Const ALLOW_NONE = "" '禁止全部
- strComputer = "."
- blnIPFilterSecurityEnabled = "False"
- arrPermittedTCPPorts = Array("80", "443", "1433", "3389", "21") '要添加的端口号
- arrPermittedUDPPorts = Array(ALLOW_NONE)
- arrPermittedIPProtocols = Array(ALLOW_ALL)
-
- Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
- SpecifyFilters
-
- Sub SpecifyFilters
-
- Set colNicConfig = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
- For Each objNicConfig in colNicConfig
- intIPSecReturn = objNicConfig.EnableIPSec(arrPermittedTCPPorts, arrPermittedUDPPorts, arrPermittedIPProtocols)
- If intIPSecReturn = 0 Then
- WScript.Echo "网卡:" & objNicConfig.ServiceName & vbcrlf & """TCP/IP筛选"" 端口和协议已经启用."
- ElseIf intIPSecReturn = 1 Then
- WScript.Echo "网卡:" & objNicConfig.ServiceName & vbcrlf & """TCP/IP筛选"" 端口和协议已经启用." & VbCrLf & "必须重新启动使更改生效."
- Else
- WScript.Echo "不通启用 网卡:" & objNicConfig.ServiceName & vbcrlf & """TCP/IP筛选"" 端口和协议."
- End If
- Next
-
- End Sub
复制代码
|