vars.bat on Windows - "reg query" change

Support forum for Easy-RSA certificate management suite.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
Alex Morris
OpenVPN User
Posts: 28
Joined: Tue Mar 04, 2014 12:38 am

vars.bat on Windows - "reg query" change

Post by Alex Morris » 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:

Code: Select all

FOR /F "tokens=2*" %%a IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\OpenVPN"') DO set "PATH=%PATH%;%%b\bin"
The important bit of that line - the REG QUERY command - returns the contents of the entire key:

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
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:

Code: Select all

reg query "hkey_local_machine\software\openvpn" /ve

HKEY_LOCAL_MACHINE\software\openvpn
    (Default)    REG_SZ    C:\Program Files\OpenVPN
As noted above, this appears to apply to W7 Ent x64 and W10 Pro x64; I can't comment for other versions.

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: vars.bat on Windows - "reg query" change

Post by TinCanTech » Fri Oct 13, 2017 10:10 am


Alex Morris
OpenVPN User
Posts: 28
Joined: Tue Mar 04, 2014 12:38 am

Re: vars.bat on Windows - "reg query" change

Post by Alex Morris » Fri Oct 13, 2017 11:25 am

Reported on the GitHub issues page as requested.

Post Reply