RogueSpear Posted September 20, 2004 Share Posted September 20, 2004 I've searched and read for hours to see if anyone posted a solution to this but didn't find any, so here is a VBscript routine I wrote a while back to do the trick. I made it into a selfcontained subroutine so you can just plop it into an existing script if you like.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.'**********************************************************************'** 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 NextEnd SubI'm noticing in preview mode that this does not look nearly as readable as in PrimalScript, but it's really not too bad in a proper editor. I just thought that I'd throw this next piece in since it's sort of topic related. A VBscript line to change the name of your network connection.ws.Run "netsh interface set interface name = ""Local Area Connection"" newname = ""APD Network""",0, True Link to comment Share on other sites More sharing options...
Noise Posted September 20, 2004 Share Posted September 20, 2004 You can also use GreenMachines awesome batch file. It's amazingly tight for a batch file. Nice work on the VBscript too. @ECHO OFFSETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONFOR /F "TOKENS=1 DELIMS= " %%A IN ('REG QUERY HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}') DO (SET TEMP1=%%ASET TEMP2=!TEMP1:~99,38!SET TEMP3=!TEMP2:~-1!IF "!TEMP3!"=="}" ( IF NOT "!TEMP2!"=="{4D36E972-E325-11CE-BFC1-08002BE10318}" ( SET REGSTR1=HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\!TEMP2!\Connection SET REGSTR2=HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\!TEMP2! REG ADD !REGSTR1! /v ShowIcon /t REG_DWORD /d 1 /f REG ADD !REGSTR2! /v IPAutoconfigurationEnabled /t REG_DWORD /d 0 /f )))Very Nice. Link to comment Share on other sites More sharing options...
a06lp Posted September 20, 2004 Share Posted September 20, 2004 what, exactly, is this doing? Link to comment Share on other sites More sharing options...
RogueSpear Posted September 20, 2004 Author Share Posted September 20, 2004 Enables the tray icon for "Local Area Connection." The one you can right click on to get Disable, Status, Repair, etc. Link to comment Share on other sites More sharing options...
big poppa pump Posted September 20, 2004 Share Posted September 20, 2004 Why go through all this hassle when this option can be specified in the winnt.sif file?[Homenet]ShowTrayIcon = Yes Link to comment Share on other sites More sharing options...
gamehead200 Posted September 20, 2004 Share Posted September 20, 2004 Why go through all this hassle when this option can be specified in the winnt.sif file?[Homenet]ShowTrayIcon = YesThat's too funny! Link to comment Share on other sites More sharing options...
GreenMachine Posted September 20, 2004 Share Posted September 20, 2004 Why go through all this hassle when this option can be specified in the winnt.sif file?[Homenet]ShowTrayIcon = YesHomeNet ... Tried that in XP Pro or Windows 2000?EDIT:: Also requires Internet Connection Sharing ... Oh Brother ...ShowTrayIconValue: Yes | NoDefault: YesEnables or disables the display of the ICS tray icon. This entry requires that EnableICS = Yes. Link to comment Share on other sites More sharing options...
big poppa pump Posted September 20, 2004 Share Posted September 20, 2004 [Homenet] Bridge = Adapter1,Adapter2 EnableICS = No ShowTrayIcon = YesHere is my homenet section in XP and it works. Link to comment Share on other sites More sharing options...
RogueSpear Posted September 21, 2004 Author Share Posted September 21, 2004 D'oh! Since I've never used ICS, and in fact disable it through group policy in most instances, I ASSumed that the homenet setting was to show the tray icon for ICS (is there one?).I suppose the bright side, if there is one, is that I learned how to step through a key in order to make a change. Not sure if I'll ever need to again...oh well.. Link to comment Share on other sites More sharing options...
RyanVM Posted September 21, 2004 Share Posted September 21, 2004 Kudos to both of you for the valiant effort, though Oh and GM, still crying about last weekend? Link to comment Share on other sites More sharing options...
a06lp Posted September 21, 2004 Share Posted September 21, 2004 Whoa, hold the phone (I cant believe I actually wrote that...)Those icons in the system tray for networks (I have LAN, and Wireless) are NOT shown by default in WinXP SP2?!?And, if not, this simple code in winnt.sif will enable them (but NOT ICS?)[Homenet]EnableICS = NoShowTrayIcon = Yes[edit]I know I removed the "Bridge = Adapter1,Adapter2" line, because I THINK it creates a bridge, correct? If so, and you DISABLED ICS, whats the point of the bridge? Link to comment Share on other sites More sharing options...
GreenMachine Posted September 21, 2004 Share Posted September 21, 2004 [Homenet]EnableICS = NoShowTrayIcon = YesDoesn't work in Windows XP Professional SP2: No Network Icon is displayed, and the box is still unchecked in Network Properties. It was a nice thought, anyway ...@RyanVM ... and it gets worse! Link to comment Share on other sites More sharing options...
Bilou_Gateux Posted September 21, 2004 Share Posted September 21, 2004 @big poppa pumpnot all people uses the latest M$ releasesWindows 2000 user here !@RogueSpear, Nois3 & GMThanks for the scripts ! Link to comment Share on other sites More sharing options...
GreenMachine Posted September 21, 2004 Share Posted September 21, 2004 Don't forget to add REG.EXE somewhere in the path, e.g. WINNT\System32. Link to comment Share on other sites More sharing options...
Bilou_Gateux Posted September 21, 2004 Share Posted September 21, 2004 @GMofftopic question ?Can i add reg.exe version 2.0 from the Windows 2000 support tools to my CD source built with the last version of XPcreate using the new functionality ?A User defined FILESCD folder may now be used in conjunction with the XPCREATE FILESCD directory.My needs is to add some M$ files (reg.exe wntipcfg.exe msconfig.exe) to this folder and let them added in dosnet.inf file and compressed in the I386 folder) without using $oem$\$$\system32 method ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now