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

#21 User is offline   RogueSpear 

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

Posted 11 October 2004 - 08:32 PM

Just made a little improvement in case there is an interest. I made a subroutine to disable NetBIOS from all network interfaces. The inspiration here is a Sierra Wireless AirCard 555. When you install this card it creates two DUN entries and a NIC adapter with NetBIOS getting it's setting from DHCP. So even if you disable NetBIOS in your WINNT.SIF file, once you install this adapter (or the Cisco VPN client by the way), NetBIOS can still run if DHCP calls for it. Personally I like to ensure that NetBIOS is never enabled. It's a bandwidth waster and a huge security hole. I have noticed better throughput VPNing with the AirCard if NetBIOS is totally shutdown.

For the tray icon subroutine, I added the ability to specify the DNS suffix to the interface "Local Area Connection". Not entirely necessary, but a nice feature when working in the enterprise.

Quote

Option Explicit
Const HKLM = &H80000002
Const REG_SZ = 1
Const REG_DWORD = 4
Dim strComputer
strComputer="."

'**********************************************************************
'** Subroutine; Disable NetBIOS from all interfaces                  **
'**********************************************************************
Sub NetBTDisable
Dim objReg, strKeyPath, strNBTOptions, dwNBTOptions, arrSubKeys, SubKey, FullKey, arrEntryNames, arrValueTypes, i, dwValue
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces"
strNBTOptions = "NetbiosOptions"
dwNBTOptions = 2
objReg.EnumKey HKLM, strKeyPath, arrSubKeys
For Each SubKey In arrSubKeys
  FullKey = strKeyPath & "\" & SubKey
  objReg.EnumValues HKLM, FullKey, arrEntryNames, arrValueTypes
  For i=0 To UBound(arrEntryNames)
      Select Case arrValueTypes(i)       
      Case REG_DWORD
          objReg.GetDWORDValue HKLM, FullKey, arrEntryNames(i),dwValue
          If arrEntryNames(i) = strNBTOptions Then objReg.SetDWORDValue HKLM, FullKey, strNBTOptions, dwNBTOptions
      End Select
      Next
    Next
End Sub

'**********************************************************************
'** Subroutine; Show the tray icon for "Local Area Connection"    **
'**********************************************************************
Sub ShowNetTrayIcon
Dim objReg, strKeyPath, strKeyPath2, strShowIcon, dwShowIcon, strDomainKey, strDomain, arrSubKeys
Dim SubKey, FullKey, FullKey2, arrEntryNames, arrValueTypes, i, strValue
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}"
strKeyPath2 = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"
strShowIcon = "ShowIcon"
strDomainKey = "Domain"
strDomain = "MyDomain.Local"
dwShowIcon = 1
objReg.EnumKey HKLM, strKeyPath, arrSubKeys
For Each SubKey In arrSubKeys
  If SubKey <> "Descriptions" Then
FullKey = strKeyPath & "\" & SubKey & "\Connection\"
FullKey2 = strKeyPath2 & "\" & SubKey
      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
            objReg.SetStringValue HKLM, FullKey2, strDomainKey, strDomain
        End If
        End Select
    Next
  End If
Next
End Sub

'**********************************************************************
'** Run tasks                                                        **
'**********************************************************************
NetBTDisable
ShowNetTrayIcon



Don't forget to change the strDomain = "MyDomain.Local" to whatever your domain is.


#22 User is offline   chrno2004 

  • Newbie
  • Group: Members
  • Posts: 28
  • Joined: 10-September 04

Posted 26 October 2004 - 10:48 AM

removed

#23 User is offline   chrno2004 

  • Newbie
  • Group: Members
  • Posts: 28
  • Joined: 10-September 04

Posted 26 October 2004 - 10:49 AM

@RogueSpear

Quote

A VBscript line to change the name of your network connection.

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


I'm getting the following error :(

Line: 1
Char: 1
Error: Object required: 'ws'
Code: 800A01A8
Source: Microsoft VBScript runtime error


#24 User is offline   RogueSpear 

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

Posted 26 October 2004 - 11:33 AM

Sorry bout that you need to add these two lines of code at the beginning of the script:

Dim ws
Set ws = WScript.CreateObject("WScript.Shell")


#25 User is offline   chrno2004 

  • Newbie
  • Group: Members
  • Posts: 28
  • Joined: 10-September 04

Posted 26 October 2004 - 04:05 PM

many thanks !

#26 User is offline   durex 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 953
  • Joined: 21-October 04

Posted 01 February 2005 - 09:19 PM

Not sure if youre still around here Rogue, but perhaps anyone who is familar with this vbscript could answer my question.

I was using the batch file version posted on the 1st page of this thread.. it worked like a charm... that was until I used it on my production system, that has firewire and vmware loaded on it.. It appears this batch file enables the network icon in the systray for EVERY network connections you have...

I only want it for my NIC.. not my firewire connection or my VMWare virtual adapters...

So my question.. does this script work so that it will only show my NICs?

btw.. Ive tried the winnt.sif entries for this and it doesnt work.. which of course is probably why there are these work arounds...

Thanks!!

#27 User is offline   Br4tt3 

  • World famous sausage eater...
  • PipPipPipPip
  • Group: Members
  • Posts: 566
  • Joined: 20-April 04

Posted 02 February 2005 - 02:56 AM

There ís a MS vbs file that will show the same network icon in the tray free to download with the BDD2.0 Business Accelerator @ MS webby. WOrked out for me...

Cu later

#28 User is offline   RogueSpear 

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

Posted 03 February 2005 - 07:42 PM

@durex If you notice the script looks for the network connection that is named "Local Area Connection". It should change only that one network connection, not all of them. I've run this script on literally dozens of different computers now (if not hundreds) and it has worked every time. Check and see if you changed something. As an example, I have one computer at work that has one NIC, one 802.11g adapter, VMware, Cisco VPN Client (which makes a virtual NIC), and firewire; it worked as expected and only turned on the one 10/100 NIC labeled "Local Area Connection".

Off topic - I never received an email notification that anybody responded to this thread which is odd. I just happened to search for it so I could reference it in another thread. Anyone else experience this kind of thing?

#29 User is offline   durex 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 953
  • Joined: 21-October 04

Posted 03 February 2005 - 09:34 PM

Thanks a bunch Rougue... so just toss this in a vbs and call it from my runonce and i should be set?

#30 User is offline   bc- 

  • Group: Members
  • Posts: 3
  • Joined: 26-January 05

Posted 04 February 2005 - 02:46 AM

i have another way on setting network interface parameters. after testing GreenMachines batchfile i noticed, its changing all network interfaces, even those not having any option for iconshow etc. (ms_ras..).
i made a new batch that first searches any pci-network adapter for its uniq id's and then goes the interfaces setup.
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

SET SHOWICON=0
SET IPCHECKINGENABLED=0
SET IACE=0

SET IFKEY=HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces
SET CLASSKEY=HKLM\SYSTEM\CurrentControlSet\Control\Class
SET ROOTKEY=HKLM\SYSTEM\CurrentControlSet\Control\Network
SET NETWORKKEY={4D36E972-E325-11CE-BFC1-08002BE10318}

FOR /F "TOKENS=1 DELIMS= " %%A IN ('REG QUERY %CLASSKEY%\%NETWORKKEY%') DO (
    SET TEMP1=%%A
    SET TEMP2=!TEMP1:~97,4!
   
    FOR /F "TOKENS=1 DELIMS= " %%C IN ('REG QUERY %CLASSKEY%\%NETWORKKEY%\!TEMP2!') DO (    
        SET TEMP4=%%C
        rem ComponentId -> pci\ven
        SET TEMP5=!TEMP4:~0,11!
        SET TEMP6=!TEMP4:~19,7!
        IF "!TEMP5!"=="ComponentId" (
            IF "!TEMP6!"=="pci\ven" (
                FOR /F "TOKENS=1 DELIMS= " %%D IN ('REG QUERY %CLASSKEY%\%NETWORKKEY%\!TEMP2!') DO (
                   SET TEMP4=%%D
                   rem NetCfgInstanceId
                   SET TEMP5=!TEMP4:~0,16!
                   SET TEMP6=!TEMP4:~24,38!
                   IF "!TEMP5!"=="NetCfgInstanceId" (                  
                       SET FOUNDIF=!TEMP6!
                       rem ShowIcon / IpCheckingEnabled
                       SET REGSTR1=%ROOTKEY%\%NETWORKKEY%\!FOUNDIF!\Connection
                         REG ADD !REGSTR1! /v ShowIcon /t REG_DWORD /d %SHOWICON% /f
                         REG ADD !REGSTR1! /v IpCheckingEnabled /t REG_DWORD /d %IPCHECKINGENABLED% /f
                       rem IPAutoconfigurationEnabled
                       SET REGSTR2=%IFKEY%\!FOUNDIF!        
                         REG ADD !REGSTR2! /v IPAutoconfigurationEnabled /t REG_DWORD /d %IACE% /f  
                       rem add custom Ndi-settings here
                       SET REGSTR3=%CLASSKEY%\%NETWORKKEY%\!TEMP2!\Ndi
                       
                   )
                )
            )
        )
    )
)


bc

#31 User is offline   RogueSpear 

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

Posted 04 February 2005 - 07:23 AM

@durex Yes, you can throw it into RunOnceEx. In fact my RunOnceEx is nothing but a series of VBscripts, about 10 of them I believe.

#32 User is offline   mc134 

  • Junior
  • Pip
  • Group: Members
  • Posts: 67
  • Joined: 15-January 04

Posted 23 February 2005 - 11:06 AM

Here is a VB script that i wrote last year and posted to this forum to turn on the network icon but to ignore the 1394 devices.

I use this in my batch file to run it...

ECHO Turning On Network Connection Icon(s)
ECHO.
ECHO Please wait...
start /wait %systemdrive%\install\Network\NetworkIcon.vbs
ECHO.

Attached File(s)



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