In the Internet, there is a number of examples of how to set an individual NIC to show icon in notification area, but you cannot find one if you want to set ALL the NICs by default. This is a required for my work and, hence, modified some of the scripts on the net and using WMI registry class to do the task.
You can download the VBS (please rename doc to vbs) script here
The WriteToLog() is my own function (show you some other days), you can replace it with WScript.echo.
Also note, I stopped indent after some levels so that it does not wrap around too much
‘==========================================
Sub SetShowIconValue
‘==========================================Const HKLM = &H80000002
Dim ServerName
Dim objRegDim CtrlNetworkKeyPath
Dim arrAdapterGUIDs, AdapterGUID
Dim AdapterGUIDConnKeyPath
Dim AdapterNameValue
Dim AdapterNameStringValue
Dim ShowIconDWORDValueServerName = “.”
‘Don’t want any errors here to kill the program
On error resume nextSet objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & _
ServerName & “\root\default:StdRegProv”)‘This path is fixed in Windows
CtrlNetworkKeyPath = “SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}”
‘grab all the subkeys, i.e. the Adapter GUIDs
objReg.EnumKey HKLM, CtrlNetworkKeyPath, arrAdapterGUIDs
for each AdapterGUID in arrAdapterGUIDs
if InStr(AdapterGUID, “{“) > 0 then ‘look for keys that looks like a GUID
AdapterGUIDConnKeyPath = CtrlNetworkKeyPath & “\” & AdapterGUID & “\Connection”
AdapterNameStringValue = “”
objReg.GetStringValue
HKLM,AdapterGUIDConnKeyPath,”Name”,AdapterNameStringValue
if AdapterNameStringValue <> “” then
WriteToLog “Looking at registry path: ” & AdapterGUIDConnKeyPath
WriteToLog “Network Name: ” & AdapterNameStringValue‘Just set all NICs regardless of their status, no harm done
objReg.SetDWORDValue HKLM,AdapterGUIDConnKeyPath,”ShowIcon”,1
if Err.Number = 0 then
WriteToLog “Show Icon value is set to: 1″else
WriteToLog “Error ” & CStr(Err.Number) & ” while trying to check ShowIcon value, ” & Err.Description
end ifelse
WriteToLog “Cannot get name for network adapter GUID:” & AdapterGUIDConnKeyPath
end if
end if
next
On error goto 0
End Sub
The code looks great but I am confused on how to run it?
It isn’t a reg file…
not a batch script…
not a Visual basic script (I could be wrong though)
How do you actually perform this tweak? It would be A great tool for my work also (as we usually set these options by hand)
Comment by rothgar — August 16, 2007 @ 5:58 pm |
rothgar,
This is a VBScript function. You need to rip it out and save it to a notepad with .vbs extension. As I mentioned also, please replace all the WriteToLog functions with WScript.echo, its my own private function (too lazy to remove, sorry).
You can create a VBS script and run it interactively as this must be runned locally, the other way is to push out the script and schedule jobs to run it locally.
Comment by saltwetfish — August 17, 2007 @ 4:34 am |
Thanks for the tip. I went ahead and replaced all of the WriteToLog functions and even all the quotes (they didn’t copy and paste correctly). and now I seem to get a error on Line 37 Char 92
AdapterGUIDConnKeyPath = CtrlNetworkKeyPath & “\” & AdapterGUID & “\Connection”AdapterNameStringValue = “”
It is right after the “\Connection”
I am not familiar with the AdapterNameStringValue so I wasn’t sure if there was a mistake or if it should be something else.
Thanks again for your help.
Comment by rothgar — August 29, 2007 @ 5:04 am |
Hi Rothgar,
Sorry about that, the formatting was messed up. Anyway, I have uploaded the VBS file and provided a link at the top of this updated posting. Its saved as DOC because wp only allows me to upload docs, please rename the extension to VBS.
Comment by saltwetfish — August 29, 2007 @ 10:33 am |
Thanks for the link. I was able to download it and run it on a XP pro machine without any errors. Only problem I found was the network icons don’t show up when connected. I checked in the network properties and the check box is also not checked to show the icon. I ran the script as administrator and I tried restarting the machine and running the script again with the same results.
Thanks again for all your help so far. If you have anything you want me to try or suggestions on how to run it with debugging feel free to email me or I will check back here on your website.
Comment by rothgar — August 29, 2007 @ 5:20 pm |
Hi Rothgar,
Sent you a private email, did not get your reply. Anyway, send me the logged output when you run the script and let me have a look.
Comment by saltwetfish — September 5, 2007 @ 1:53 am |
Doesn’t appear to work… too bad.
Comment by Me — December 19, 2007 @ 12:05 am |
Hi Me…
Please let me know what errors you encountered and how you executed the script. Can’t help you much with that one-liner
Comment by saltwetfish — December 19, 2007 @ 2:27 am |
Work Well, author have to publish vbs file with txt file extention because copy/paste request some comprehensive vbs understanding and/or vbs skills.
the main issue is due to blog/html paging. the line “objReg.GetStringValue HKLM,AdapterGUIDConnKeyPath,”Name”,AdapterNameStringValue” should be in the same line and not on more …
Thanks a lot.
Comment by Eve — February 14, 2008 @ 9:33 am |