Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Script to rename Network Connection

Featured Replies

I recently installed openvpn on my server and one client. I wanted to setup a script to install the rest of the clients the part that is difficult is renaming the Network connection.

Is there a tool that will list the network connections and their drivers? either as command line tools or

Something that has a similar output to

|driver|------------------------------------------------|networkconnection|

|Realtek PCIe GBE Family Controller--------|Local Area Connection|

|TAP-Win32 Adapter V9|------------------------|Local Area Connection 2|

I want to create some sort of script be it batch or cscript to find the connection with the driver

TAP-Win32 Adapter V9 and rename it from its current name to tap0901

I didn't find any tools but with some registry hacking I created the following script to modify the name of the network device to what is in my client.ovpn configuration file


setlocal EnableDelayedExpansion
set "networkfile=%HOMEDRIVE%%HOMEPATH%\networks.reg"
set "driversfile=%HOMEDRIVE%%HOMEPATH%\nodes.txt"
set "openvpncfg=%ProgramFiles%\OpenVPN\config\client.ovpn"

regedit.exe /e "%networkfile%" HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
type "%networkfile%" | findstr "NetCfgInstanceId DriverDesc" > "%driversfile%"
del "%networkfile%"

set "node="
FOR /F "tokens=1,2 delims==" %%A IN ('type "%driversfile%"') DO (
set "lastnode=!node!"
set "node=%%B"
set "test=%%A"
if [!test!] == ["DriverDesc"] (
if [!node!] == ["TAP-Win32 Adapter V9"] (
set "TAPINTERFACE=!lastnode:~1,-1!"
)
)
)
type "%openvpncfg%" | findstr dev-node > "%driversfile%"
FOR /F "tokens=1,2" %%A IN ('type "%driversfile%"') DO (
if [%%A] == [dev-node] (
set "nodename=%%B"
)
)
del "%driversfile%"

echo Windows Registry Editor Version 5.00 > "%networkfile%"
echo. >> "%networkfile%"
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\%TAPINTERFACE%

\Connection] >> "%networkfile%"
echo "Name"="%nodename%" >> "%networkfile%"

regedit.exe /s "%networkfile%"
del "%networkfile%"

Edited by jeff.sadowski


Tip: avoid using ControlSetxxx when using scripts locally from within the running OS - use instead CurrentControlSet - this avoids a problem where nothing appears to happen because the control set in use is something other than 001 (e.g. Last Known Good has ever been invoked on that machine).

If you were running offline or remotely, then there is no "CurrentControlSet", and instead you would need to look at the data held in the REG_DWORD value named Current under the key HKEY_LOCAL_MACHINE\SYSTEM\Select, then use this (padded out to 3 digits) to open keys & read values under HKEY_LOCAL_MACHINE\SYSTEM\ControlSetxxx.

Just a heads-up in case you find the script works on most, but not all the clients ;)

I recently installed openvpn on my server and one client. I wanted to setup a script to install the rest of the clients the part that is difficult is renaming the Network connection.

Is there a tool that will list the network connections and their drivers? either as command line tools or

This seems like an example of where WMI/WMIC may come useful.

Only partially UNrelated:

jaclaz

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.