Command-line installation of OpenVPN

OpenVPN’s installer allows for command-line based (silent) installation, but this feature is not actually documented explicitly anywhere. Here’s all I could find – hope this list will help someone in the same situation I was in.

Starting with version 2.5, using .msi installer (thanks to Bob S for pointing this out):

You need to run the installer using msiexec, with parameters:

/i           - the installer file
/passive     - run as silent
ADDLOCAL=    - choose what to install, including:
             - OpenVPN.Service
             - OpenVPN
             - OpenVPN.GUI
             - OpenVPN.GUI.OnLogon
             - Drivers
             - Drivers.Wintun
             - Drivers.TAPWindows6
PRODUCTDIR=  - target directory

e.g.:
msiexec /i OpenVPN-2.5.msi ADDLOCAL=OpenVPN.Service,OpenVPN,Drivers,Drivers.Wintun /passive

Original article (pre version 2.5):

The installer allows you to specify is the installation should be “silent” (i.e. no GUI, nothing to click on), to specify custom installation directory (esp. useful if included in another installer, e.g. NSIS, and installing in the same directory as the target app), and components to install.

The parameters can be used even when you’re not using the silent installation, to customize behavior of the graphical installer.

/S      - silent installation
/D=path - specify a custom installation path

Note – the /D parameter has to appear last on the command line, and the path may not be inclosed in quotes. The installer simply takes all of the command line left, and uses it as path (thus supporting spaces in the path).

To select individual OpenVPN components (1 = install, 0 = do not install; the values below indicate defaults):

/SELECT_SHORTCUTS=1              - create the start menu shortcuts
/SELECT_OPENVPN=1                - OpenVPN itself
/SELECT_SERVICE=1                - install the OpenVPN service
/SELECT_TAP=1                    - install the TAP device driver
/SELECT_OPENVPNGUI=1             - install the default OpenVPN GUI
/SELECT_ASSOCIATIONS=1           - associate with .ovpn files
/SELECT_OPENSSL_UTILITIES=0      - install the utilities for generating public-private key pairs
/SELECT_EASYRSA=0                - install the RSA X509 certificate management scripts
/SELECT_PATH=1                   - add openvpn.exe in PATH
/SELECT_OPENSSLDLLS=1            - dependencies - OpenSSL DLL's
/SELECT_LZODLLS=1                - dependencies - LZO compressor DLL's
/SELECT_PKCS11DLLS=1             - dependencies - PCKS#11 DLL's

18 responses to “Command-line installation of OpenVPN

  1. @Brian Goff

    You have to export / install the *.p7b Cert File (import to Cert Store) of OpenVPN before you install OpenPVN. You can automate that with the Std Windows Shell.

  2. Very good! Thanks!
    If you want to change the option on Services to OpenVPN service start automatically from command line, just use: sc config OpenVPNService start= auto
    Note the need for the space after =
    To start it imediately: net start OpenVPNService
    Hope it helps someone

  3. @JustChecking

    I tried all the OpenVPN components to install the OpenVPN 2.4.5.601 silently in a same way using Powershell but while installation is in progress I am getting the following error

    “An error occurred installing tap device driver”

    Could you please help me out

    Thanks

  4. Hi,

    I am installing OpenVPN 2.4.5.601 in a silent process using power-shell and by default all options are selected except Easyrsa and Disable password features, next wizard path to programfiles folder and selected readme.txt at final wizard.

    Here I need your help can you please tell me
    1)how to check the both Easyrsa and Disable password features in a silent process
    2)Change the default path to programfiles(x86) in a silent process
    3)Uncheck the readme.txt file in a silent process

    Any help appreciated,
    Thanks

  5. Is there an option to install it unattended like adding the proper switches to the command-line so that it doesn’t prompt for anything?

    Thanks.

  6. I’m building a script to automate several post install tasks for windows 10 PCs. I install openVPN silently. A registry entry is added to run to auto connect to the VPN at start up. But, the default for OpenVPN install is to launch OpenVPN at user logon (Advanced option on installer). This results in an error “OpenVPN is already running”. T

    o work around this I have added a REG DELETE OpenVPN-GUI to delete the startup entry, but it would be be better if there was a switch to disabled it during the silent install. Eg /SELECT_AUTOSTART=0

  7. Pingback: OpenVPN installer added – Andreas' blog

  8. Useful information. Thank you so much. Could you please post how to install OpenVPN and configure it on the Windows docker container?

Leave a comment