描述
检索有关计算机上所有活动网络连接的信息。
有关在这段代码中使用的 Win32_NetworkConnection 类别的更多信息,请单击 此处。
支持平台
Windows Server 2003 |
是 |
Windows XP |
是 |
Windows 2000 |
是 |
Windows NT 4.0 |
Yes, with WMI installed |
脚本代码
复制代码 代码如下:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkConnection")
For Each objItem in colItems
Wscript.Echo "Access Mask: " & objItem.AccessMask
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Connection State: " & objItem.ConnectionState
Wscript.Echo "Connection Type: " & objItem.ConnectionType
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Display Type: " & objItem.DisplayType
Wscript.Echo "Local Name: " & objItem.LocalName
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Persistent: " & objItem.Persistent
Wscript.Echo "Provider Name: " & objItem.ProviderName
Wscript.Echo "Remote Name: " & objItem.RemoteName
Wscript.Echo "Remote Path: " & objItem.RemotePath
Wscript.Echo "Resource Type: " & objItem.ResourceType
Wscript.Echo "User Name: " & objItem.UserName
Wscript.Echo
Next