TapRenameScript on Windows 10 does not work
https://community.openvpn.net/openvpn/w ... nameScript
findstr parses in reverse on Windows 7 / XP where it parses normally on Windows 10.
This breaks this script.
TapRenameScript on Windows 10 does not work
Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech
-
- OpenVpn Newbie
- Posts: 6
- Joined: Mon Jul 25, 2016 9:58 am
-
- OpenVpn Newbie
- Posts: 6
- Joined: Mon Jul 25, 2016 9:58 am
Re: TapRenameScript on Windows 10 does not work
OK modified the script so it works on Windows 10.
Be carefull, this only works on Windows 10. It will do the wrong thing on Windows 7!!
Be carefull, this only works on Windows 10. It will do the wrong thing on Windows 7!!
Code: Select all
:: Rename adapter to OpenVPN on Windows 10
setlocal EnableDelayedExpansion
set "networkfile=%HOMEDRIVE%\networks.reg"
set "driversfile=%HOMEDRIVE%\nodes.txt"
regedit.exe /e "%networkfile%" HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\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 "node=%%B"
set "test=%%A"
set "lastnode=!node!"
if [!VPNfound!] == [YES] (
set "TAPINTERFACE=!lastnode:~1,-1!"
set "VPNfound=NO"
)
if [!test!] == ["DriverDesc"] (
if [!node!] == ["TAP-Windows Adapter V9"] (
set "VPNfound=YES"
)
)
)
del "%driversfile%"
echo Windows Registry Editor Version 5.00 > "%networkfile%"
echo. >> "%networkfile%"
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\%TAPINTERFACE%\Connection] >> "%networkfile%"
echo "Name"="OpenVPN" >> "%networkfile%"
regedit.exe /s "%networkfile%"
del "%networkfile%"