vars.bat on Windows - "reg query" change
Posted: Fri Oct 13, 2017 9:22 am
Apologies if this has already been spotted - I've tried searching for this but without success.
I have tested this on both Windows 7 Enterprise x64 and Windows 10 Pro x64. I don't know if the same behaviour occurs in other versions of Windows. Other people with other versions of Windows may be able to test and verify.
I'm using the version of easy-rsa which was bundled with OpenVPN v2.4.4, installed by default into C:\Program Files\OpenVPN.
The vars.bat.sample script contains this line:
The important bit of that line - the REG QUERY command - returns the contents of the entire key:
As a result, the variable %%b is set to the final result of the REG QUERY command, i.e. "OpenVPN Administrators", and the PATH environment variable then ends with "';OpenVPN Administrators\bin", which doesn't find the openssl.exe binary.
Instead, the variable %%b should be set to the (Default) value of the key: "C:\Program Files\OpenVPN".
The REG QUERY command supports the switch "/ve" to restrict the result to the (Default) value:
As noted above, this appears to apply to W7 Ent x64 and W10 Pro x64; I can't comment for other versions.
I have tested this on both Windows 7 Enterprise x64 and Windows 10 Pro x64. I don't know if the same behaviour occurs in other versions of Windows. Other people with other versions of Windows may be able to test and verify.
I'm using the version of easy-rsa which was bundled with OpenVPN v2.4.4, installed by default into C:\Program Files\OpenVPN.
The vars.bat.sample script contains this line:
Code: Select all
FOR /F "tokens=2*" %%a IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\OpenVPN"') DO set "PATH=%PATH%;%%b\bin"
Code: Select all
reg query "hkey_local_machine\software\openvpn"
HKEY_LOCAL_MACHINE\software\openvpn
config_dir REG_SZ C:\Program Files\OpenVPN\config
config_ext REG_SZ ovpn
exe_path REG_SZ C:\Program Files\OpenVPN\bin\openvpn.exe
log_dir REG_SZ C:\Program Files\OpenVPN\log
priority REG_SZ NORMAL_PRIORITY_CLASS
log_append REG_SZ 0
(Default) REG_SZ C:\Program Files\OpenVPN
disable_save_passwords REG_DWORD 0x0
ovpn_admin_group REG_SZ OpenVPN Administrators
Instead, the variable %%b should be set to the (Default) value of the key: "C:\Program Files\OpenVPN".
The REG QUERY command supports the switch "/ve" to restrict the result to the (Default) value:
Code: Select all
reg query "hkey_local_machine\software\openvpn" /ve
HKEY_LOCAL_MACHINE\software\openvpn
(Default) REG_SZ C:\Program Files\OpenVPN