Re: Rename network connection
- From: Tomáš Krbec <Tomáš Krbec@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 12 Jul 2006 02:56:01 -0700
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?
"Thijs from Fico" wrote:
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
- Prev by Date: Re: XP Pro with embedded extensions
- Next by Date: Re: Splash Screens
- Previous by thread: Re: Splash Screens
- Next by thread: Problems with "HAL.DLL" not found
- Index(es):
Relevant Pages
|