This bugger drove me nuts for a while and in fact was one of the primary reasons I took up VBscript several years ago. The connection state is under a key where part of the name contains the GUID for your NIC. Thus it's different for every computer. If you have a multihomed machine, you'll need to do some tweaking to enable the tray icon for both NICs.
Quote
'** Subroutine; Show the tray icon for the network connection **
'**********************************************************************
Sub NetTrayIcon
Dim strComputer, objReg, strKeyPath, strShowIcon, dwShowIcon, arrSubKeys, SubKey, FullKey
Dim arrEntryNames, arrValueTypes, i, strValue
strComputer = "."
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}"
strShowIcon = "ShowIcon"
dwShowIcon = 1
objReg.EnumKey HKLM, strKeyPath, arrSubKeys
For Each SubKey In arrSubKeys
If SubKey <> "Descriptions" Then
FullKey = strKeyPath & "\" & SubKey & "\Connection\"
objReg.EnumValues HKLM, FullKey, arrEntryNames, arrValueTypes
For i=0 To UBound(arrEntryNames)
Select Case arrValueTypes(i)
Case REG_SZ
objReg.GetStringValue HKLM, FullKey, arrEntryNames(i),strValue
If strValue = "Local Area Connection" Then
objReg.SetDWORDValue HKLM, FullKey, strShowIcon, dwShowIcon
End If
End Select
Next
End If
Next
End Sub
Quote



Help

Back to top









