welcome_msg = "网络连接搜索测试"
Set WSHNetwork = WScript.CreateObject("WScript.Network")
’创建一个网络对象
Set oPrinters = WshNetwork.EnumPrinterConnections
’创建一个网络打印机连接列表
WScript.Echo "Network printer mappings:"
For i = 0 to oPrinters.Count - 1Step2
’显示网络打印机连接情况
WScript.Echo "Port "&oPrinters.Item(i)
& " = " & oPrinters.Item(i+1)
Next
Set colDrives = WSHNetwork.EnumNetworkDrives
’创建一个网络共享连接列表
If colDrives.Count = 0 Then
MsgBox "没有可列出的驱动器。",
vbInformation + vbOkOnly,welcome_msg
Else
strMsg = "当前网络驱动器连接: " &CRLF
Fori=0To colDrives.Count - 1 Step 2
strMsg = strMsg & Chr(13)&Chr(10)&colDrives(i)
& Chr(9)&colDrives(i+1)
Next
MsgBox strMsg, vbInformation + vbOkOnly,
welcome_msg’显示当前网络驱动器连接
End If |