Help - Search - Members - Calendar
Full Version: Script to modify Local Area Connection (HELP)
MSFN Forums > Customizing Windows and Graphics > Customizing Windows

   
Google Internet Forums Unattended CD/DVD Guide
Tw_ix
I want to do the following for a Local Area Connection (under Windows XP):
- Modify the name of the connection (rename Local Area Connection to Corporate Network
- Enable the option ShowIcon (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\{GUID of Adapter}\Connection\ShowIcon) ???
- Modify DNS Search List (HKLM\System\CurrentControlSet\Services\TCPIP\Parameters\SearchList) ???
- Enable NetBIOS (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcp_{GUID of Adapter}\NetbiosOptions) ???

The problem is that on the machine I want to do this there are several connections (nic, wireless, vpn) and I don't know how to find the correct entries in the registries. The connection related ones must only by applied on the nic connection (not on the other two).

My idea was to use the IP address. The script I want to use will run while the nic is connected to our LAN. So I know a part of the IP range (first to octects).

I would like to do this via VBS. After google-ling a bit a round I create the following:

Const cIPOctet_1="192"
Const cIPOctet_2="168"
Const cConnectionName="Corporate Network"

Const NETWORK_CONNECTIONS = &H31&

Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colNicConfigs = oWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
Set oShell = CreateObject("Shell.Application")
Set oFolder = oShell.Namespace(NETWORK_CONNECTIONS)

For Each oNicCfg In colNicConfigs
Set oNic = oWMIService.Get("Win32_NetworkAdapter.DeviceID=" & oNicCfg.Index)
For Each vIPAddress In oNicCfg.IPAddress
aOctets = Split(vIPAddress, ".")
If aOctets(0)=cIPOctet_1 And aOctets(1)=cIPOctet_2 Then vConnectionToRename=oNic.NetConnectionID
Next
Next

If vConnectionToRename <> "" and vConnectionToRename <> cConnectionName Then
Set colItems = oFolder.Items
For Each oItem in colItems
If oItem.Name = vConnectionToRename Then oItem.Name = cConnectionName
Next
End If

Set oWMIService = Nothing
Set colNicConfigs = Nothing
Set oShell = Nothing
Set oFolder = Nothing

The first part of the scripts finds the current name of the connection via the two first octets of the IP. Once the connection name is found the second part of the script loops until the name found before is detected and then renames it to the new name. This works!

But I now want to modify
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\{GUID of Adapter}\Connection\ShowIcon
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcp_{GUID of Adapter}\NetbiosOptions
But how can I detect this {GUID of Adapter} ??? I have the IP address of the connection and the connection name. Is there a way to query via VBS to find this GUID?

Can any one help? I have soon a major roll-out and need this script!

Many many thanks!

blushing.gif

Take care,
Twixy
allen2
Try via netsh command.
maxximum
Try : Windows XP SP2 Post Install Script Pack V1.02 !
It can rename your LAN connection with script "200_ConfigNetwork.vbs" found in the pack.
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.