Below is a script to check if a LAN cables is plugged in. I run the script
on XP and it works great. I found out when running on a Windows 2000 box I
get an error. It appears that there are additional wmi properties. Does
anyone know if there is a WMI update or download to WMI for Windows 2000? I
am not sure what version of WMI is installed otherwise, I would have posted.
' connect to WMI and retrieve collection.
Set objSet = GetObject("WinMgmts:").ExecQuery _
("select * from Win32_NetworkAdapter WHERE DeviceID = '1' ")
'Get final value and display result.
For Each obj in objSet
strStatus = obj.NetConnectionStatus
'Err.Number = obj.NetConnectionStatus
Next
WScript.Echo strStatus
If strStatus = 2 Then
WScript.Echo "connected"
Wscript.Quit 0
elseif strStatus = 7 Then
WScript.Echo "Not Connected"
WScript.Quit 1
End if