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

Re: wmi property by Andrew

Andrew
Tue Sep 13 14:09:26 CDT 2005

What error do you get?


--
Andrew C. Madsen
Network Specialist
Harley-Davidson Motor Company
"Big D" <BigDaddy@newsgroup.nospam> wrote in message
news:OSIpaQJuFHA.1364@tk2msftngp13.phx.gbl...
> 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
>
>



Re: wmi property by Jonathan

Jonathan
Tue Sep 13 15:17:01 CDT 2005

This property is not available on Windows 2000. Only on Windows XP and
above.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Big D" <BigDaddy@newsgroup.nospam> wrote in message
news:OSIpaQJuFHA.1364@tk2msftngp13.phx.gbl...
> 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
>