I have written a powershell script to set specific registry keys as a part of the installation of Open VPN. This configures OpenVPN GUI to look at the C:\Program Files\OpenVPN\OpenVPN folder to get it's configuration, amung other configurations.
Here's the script
#Set Registry for Open VPN GUI
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "allow_edit" /T REG_SZ /D "1" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "allow_password" /T REG_SZ /D "1" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "allow_proxy" /T REG_SZ /D "1" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "allow_service" /T REG_SZ /D "0" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "config_dir" /T REG_SZ /D "C:\Program Files\OpenVPN\OpenVPN\config" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "config_ext" /T REG_SZ /D "ovpn" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "connectscript_timeout" /T REG_SZ /D "15" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "disconnect_on_suspend" /T REG_SZ /D "0" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "disconnectscript_timeout" /T REG_SZ /D "10" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "editor" /T REG_SZ /D "C:\WINDOWS\notepad.exe" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "exe_path" /T REG_SZ /D "C:\Program Files\OpenVPN\bin\openvpn.exe" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "log_append" /T REG_SZ /D "0" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "log_dir" /T REG_SZ /D "C:\Program Files\OpenVPN\OpenVPN\log" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "log_viewer" /T REG_SZ /D "C:\WINDOWS\notepad.exe" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "preconnectscript_timeout" /T REG_SZ /D "10" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "priority" /T REG_SZ /D "NORMAL_PRIORITY_CLASS" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "service_only" /T REG_SZ /D "0" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "show_balloon" /T REG_SZ /D "1" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "show_script_window" /T REG_SZ /D "1" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "silent_connection" /T REG_SZ /D "0" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /V "passphrase_attempts" /T REG_SZ /D "3" /F
When i run the script locally, it does exactly what i need it to do, when deployed via intune it creates the reg keys in different location
When run locally it creates the keys here HKLM\SOFTWARE\OpenVPN-GUI
When deployed via Intune, the Keys are created here HKLM\SOFTWARE\WOW6432Node\OpenVPN-GUI
I undestand from the name that intune will to deploy it as a 32bit app so this could be my problem.
Is there any way round this?
You can either re-launch the script using the 64-bit version of powershell.exe
:
if([System.Environment]::Is64BitOperatingSystem -and -not [System.Environment]::Is64BitProcess){
Start-Process $ENV:WINDIR\sysnative\WindowsPowershell\v1.0\PowerShell.exe -File "$PSCommandPath"
exit
}
# rest of script
... or instruct reg.exe
to target the 64-bit view of the registry (/REG:64
):
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /REG:64 /V "allow_edit" /T REG_SZ /D "1" /F
REG ADD "HKLM\SOFTWARE\OpenVPN-GUI" /REG:64 /V "allow_password" /T REG_SZ /D "1" /F
# etc....