MSFN Forum: Activate the Network Tray Icon - MSFN Forum

Jump to content



  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Activate the Network Tray Icon Rate Topic: -----

#1 User is offline   RogueSpear 

  • OS: SimplyMEPIS
  • Group: Supreme Sponsor
  • Posts: 1,529
  • Joined: 18-September 04

  Posted 20 September 2004 - 01:22 PM

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.

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
I'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.

Quote

ws.Run "netsh interface set interface name = ""Local Area Connection"" newname = ""APD Network""",0, True



#2 User is offline   Noise 

  • Windows Guru
  • PipPipPip
  • Group: Members
  • Posts: 425
  • Joined: 27-February 04

Posted 20 September 2004 - 01:37 PM

You can also use GreenMachines awesome batch file. It's amazingly tight for a batch file. Nice work on the VBscript too.
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

FOR /F "TOKENS=1 DELIMS= " %%A IN ('REG QUERY HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}') DO (

SET TEMP1=%%A
SET 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.

#3 User is offline   a06lp 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 976
  • Joined: 19-August 04

Posted 20 September 2004 - 02:35 PM

what, exactly, is this doing?

#4 User is offline   RogueSpear 

  • OS: SimplyMEPIS
  • Group: Supreme Sponsor
  • Posts: 1,529
  • Joined: 18-September 04

Posted 20 September 2004 - 03:20 PM

Enables the tray icon for "Local Area Connection." The one you can right click on to get Disable, Status, Repair, etc.

#5 User is offline   big poppa pump 

  • Damn Newbies!!
  • PipPipPip
  • Group: Members
  • Posts: 406
  • Joined: 10-September 03

Posted 20 September 2004 - 04:22 PM

Why go through all this hassle when this option can be specified in the winnt.sif file?

[Homenet]
ShowTrayIcon = Yes

#6 User is offline   gamehead200 

  • SEARCH!!! SEARCH!!!
  • Group: Super Moderator
  • Posts: 7,019
  • Joined: 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 20 September 2004 - 04:23 PM

big poppa pump, on Sep 20 2004, 06:22 PM, said:

Why go through all this hassle when this option can be specified in the winnt.sif file?

[Homenet]
ShowTrayIcon = Yes

That's too funny! :lol:

#7 User is offline   GreenMachine 

  • ineXPlicable
  • Group: Developers
  • Posts: 3,062
  • Joined: 22-August 03

Posted 20 September 2004 - 04:47 PM

big poppa pump, on Sep 20 2004, 03:22 PM, said:

Why go through all this hassle when this option can be specified in the winnt.sif file?

[Homenet]
ShowTrayIcon = Yes

HomeNet ... Tried that in XP Pro or Windows 2000?

EDIT:: Also requires Internet Connection Sharing ... Oh Brother ...

Quote

ShowTrayIcon
Value: Yes | No
Default: Yes


Enables or disables the display of the ICS tray icon. This entry requires that EnableICS = Yes.


#8 User is offline   big poppa pump 

  • Damn Newbies!!
  • PipPipPip
  • Group: Members
  • Posts: 406
  • Joined: 10-September 03

Posted 20 September 2004 - 05:04 PM

[Homenet]
Bridge = Adapter1,Adapter2
EnableICS = No
ShowTrayIcon = Yes

Here is my homenet section in XP and it works.

#9 User is offline   RogueSpear 

  • OS: SimplyMEPIS
  • Group: Supreme Sponsor
  • Posts: 1,529
  • Joined: 18-September 04

  Posted 20 September 2004 - 07:21 PM

:blushing: 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..

#10 User is offline   RyanVM 

  • Like a big surly teddy bear.
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,661
  • Joined: 31-August 03

Posted 20 September 2004 - 08:42 PM

:lol:

Kudos to both of you for the valiant effort, though :P

Oh and GM, still crying about last weekend? ;) :D

#11 User is offline   a06lp 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 976
  • Joined: 19-August 04

Posted 20 September 2004 - 08:56 PM

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 = No
ShowTrayIcon = 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?

#12 User is offline   GreenMachine 

  • ineXPlicable
  • Group: Developers
  • Posts: 3,062
  • Joined: 22-August 03

Posted 21 September 2004 - 12:57 AM

[Homenet]
EnableICS = No
ShowTrayIcon = Yes
Doesn'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!

#13 User is offline   Bilou_Gateux 

  • Powered by Windows Embedded
  • PipPipPipPipPip
  • Group: Members
  • Posts: 766
  • Joined: 03-January 04

Posted 21 September 2004 - 01:34 AM

@big poppa pump
not all people uses the latest M$ releases
Windows 2000 user here !

@RogueSpear, Nois3 & GM
Thanks for the scripts !

#14 User is offline   GreenMachine 

  • ineXPlicable
  • Group: Developers
  • Posts: 3,062
  • Joined: 22-August 03

Posted 21 September 2004 - 01:39 AM

Don't forget to add REG.EXE somewhere in the path, e.g. WINNT\System32.

#15 User is offline   Bilou_Gateux 

  • Powered by Windows Embedded
  • PipPipPipPipPip
  • Group: Members
  • Posts: 766
  • Joined: 03-January 04

Posted 21 September 2004 - 01:46 AM

@GM

offtopic 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 ?

Quote

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 ?

#16 User is offline   GreenMachine 

  • ineXPlicable
  • Group: Developers
  • Posts: 3,062
  • Joined: 22-August 03

Posted 21 September 2004 - 02:08 AM

Sorry , no ... USERFILESCD is the same as FILESCD, if just allows the user to point to it. I would just make a switchless self extractor that copies the files to System32. IEXPRESS and a Command Script would work. That could run from SVCPACK.INF (SVC-EXE would get it there.)

#17 User is offline   RogueSpear 

  • OS: SimplyMEPIS
  • Group: Supreme Sponsor
  • Posts: 1,529
  • Joined: 18-September 04

Posted 21 September 2004 - 05:46 AM

Quote

Doesn'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 ...


What's this? Vindication? :P

Anyway something I forgot is that you need to specify REG_SZ as a constant equal to 1 if you decide to use the subroutine.

#18 User is offline   Sanjay 

  • Member
  • PipPip
  • Group: Members
  • Posts: 273
  • Joined: 13-August 04

Posted 11 October 2004 - 06:36 AM

I am a little confused here. Does big poppa pump's winnt.sif method work or not?
[Homenet]
ShowTrayIcon = Yes

If the above does nto work, then what is the simplest method to make the 'Network Tray Icon' appear in unattended install?

#19 User is offline   a06lp 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 976
  • Joined: 19-August 04

Posted 11 October 2004 - 07:06 AM

try this:

http://www.msfn.org/board/index.php?showtopic=23271&hl=

#20 User is offline   Sanjay 

  • Member
  • PipPip
  • Group: Members
  • Posts: 273
  • Joined: 13-August 04

Posted 11 October 2004 - 11:07 AM

@a06lp
Thanks.

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy