Rename network connection

G

Guest

I want to rename my LAN connections using a script at the end of FBA.
I'm using a FBA generic command at phase 8500
FilePath: %11%\cmd.exe
Arguments: /c "%11%\ChangeConnectionNames.vbs"

But it doesn't work. The FBAlog.txt reports:
17:03:30 PM - [FBALaunch] C:\WINDOWS\system32\cmd.exe /c
"C:\WINDOWS\system32\ChangeConnectionNames.vbs" (ExitCode: 0x1)

If I run it manually on the target system after the first boot it run fine
and renames
my LAN connections.

Any ideas to why??

Thijs

The script ChangeConnectionNames.vbs:
------------------------------------
Const NETWORK_CONNECTIONS = &H31&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS)

Set colItems = objFolder.Items
For Each objItem in colItems
If objItem.Name = "Local Area Connection" Then
objItem.Name = "Machine"
End If
If objItem.Name = "Local Area Connection 2" Then
objItem.Name = "Network"
End If

Next
---------------------------
 
M

Martin Grossen, eMVP [AVNET Silica]

Again, don't use %10% variables.
Use %SYSTEMROOT%

--

Martin Grossen, eMVP

AVNET EMG Silica
Franchise Manager Microsoft Embedded Europe

Your competent partner for Microsoft Embedded licencing

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
G

Guest

Nope, that isn't it.

The problem here is that the network adapters are properly named (Local
Area Connection) until
the first start of the explorer.exe. Before this they just have some
GUID-like ID as name.
So trying this before the first start of the explorer doesn't work.

========================================
Const NETWORK_CONNECTIONS = &H31&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS)

Set colItems = objFolder.Items
For Each objItem in colItems
If objItem.Name = "Local Area Connection" Then
objItem.Name = "Machine"
End If
If objItem.Name = "Local Area Connection 2" Then
objItem.Name = "Network"
End If
Next
=======================================

First I dumped the VBS-script for renaming my LAN connection when I found
out that netsh can do the same. Then
I in found a call to rename the connections, used when there is no explorer
shell at all. This all resulted
in the batch file below

=============================================

@echo off

set COUNT=1
:NAME
echo.
echo Naming network adapters . . . (try=%COUNT%)
rundll32.exe netshell.dll HrRenameConnection
netsh.exe interface show interface name="Local Area Connection">NULL
set /a COUNT=%COUNT%+1
if %errorlevel%==1 goto NAME
echo.
echo Successfully named all network adapters

set COUNT=1
:RENAME_1
echo.
echo Renaming network adapter "Local Area Network" to "Machine" . . .
(try=%COUNT%)
netsh.exe interface set interface name="Local Area Connection"
newname="Machine"
set /a COUNT=%COUNT%+1
if %errorlevel%==1 goto RENAME_1
echo Successfully renamed network adapter

set COUNT=1
:RENAME_2
echo.
echo Renaming network adapter "Local Area Network 2" to "Network" . . .
(try=%COUNT%)
netsh.exe interface set interface name="Local Area Connection 2"
newname="Network"
set /a COUNT=%COUNT%+1
if %errorlevel%==1 goto RENAME_2
echo Successfully renamed network adapter

set COUNT=1
:CONFIG
echo.
echo Configuring adapter "Machine" . . . (try=%COUNT%)
netsh.exe interface ip set address name="Machine" source=static
addr=194.120.123.71 mask=255.255.255.0
set /a COUNT=%COUNT%+1
if %errorlevel%==1 goto CONFIG
echo Successfully configured network adapter

set COUNT=1
:FIREWALL
echo.
echo Disabling Windows Firewall . . . (try=%COUNT%)
netsh.exe firewall set opmode mode=DISABLE
set /a COUNT=%COUNT%+1
if %errorlevel%==1 goto FIREWALL
echo Successfully disabled Windows Firewall
:END
=========================================


Thijs
 
G

Guest

This method is fine, but only when I use english language. Eg. for Czech
language, after I call
rundll32.exe netshell.dll HrRenameConnection
the connection has name
"Připojení k místní síti" in explorer and
"P²ipojení k místní síti" in cmd window.

How can I wrote an "universal" batch file for all language mutation?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top