This handy NSIS installer script installs both OpenVPN as well as a set of configuration data. It makes it super easy to package and distribute OpenVPN and Configurations to Windows users (like in a corporate environment)

Building OpenVPN Installer

These commands will be executed from the Windows command line, these for example come from our make.bat file.

c:\Program Files\NSIS\makensis.exe \
    /Doutput_exe="vpn-output.exe" \
    /Dclient_cfg="vpn-config" \

Update the comamnd to substitue the desired configuration directory for vpn-config. Also, other files will need to be preset, such as logo icons or images.<

OpenVPN Installer Directory Structure


Nullsoft Installer for OpenVPN

# OpenVPN Application and Configuration Installer
# @version $Id$

# Set Defaults
# Allows for /DOUTPUT_EXE=something.exe /DCLIENT_CFG=config\file.cfg

!ifndef CONFIG_DIR
    !define CONFIG_DIR "config"

!ifndef OUTPUT_EXE
    !define OUTPUT_EXE "vpn-install.exe"

BrandingText "Edoceo OpenVPN Installer"
Caption "Edoceo Automagic OpenVPN Installer"
CompletedText "Edoceo Automagic OpenVPN Installation Complete"
# ComponentText "OpenVPN"
Icon images\logo.ico
InstallColors 336699 333333
InstProgressFlags colored smooth
Name "OpenVPN Installer"
RequestExecutionLevel admin
ShowInstDetails show
XPStyle off
# TargetMinimalOS 5.1

Section ""

#    Var /GLOBAL targetdir

    # Maybe warn that directory is not here?
    # @todo check for OpenVPN Dir in Registry

    DetailPrint "Checking OpenVPN"
    IfFileExists "$PROGRAMFILES32\OpenVPN\bin\openvpn-gui-1.0.3.exe" goodVPN failVPN
        MessageBox MB_OK "We must install OpenVPN First, please complete the following installer choosing Next or Continue as necessary"
        SetOutPath $EXEDIR
        DetailPrint "Extracting OpenVPN $OUTDIR"
        # Bundle OpenVPN Installer
        File source\openvpn-2.2.2-install.exe
        # ExecShell "open" "$EXEDIR\openvpn-2.1.1-install.exe"
        ExecWait "$EXEDIR\openvpn-2.2.2-install.exe" $0
        # Zero == Success, One == Fail, handle
        IntCmp $0 0 goodInstall
            DetailPrint "Failed to Install: $0"
            MessageBox MB_OK|MB_ICONSTOP "Failed to install OpenVPN, this is required to continue. Installation aborted."
        Goto doneVPN
        DetailPrint "OpenVPN Already Installed"

    # @todo read registry for install values?
    # @todo find the registry entries for the OpenVPN configuration
    # ReadRegStr $0 HKLM Software\
    # SetOutPath $0
    SetOutPath "$PROGRAMFILES32\OpenVPN\config"

    # Full contents of Config
    File /r /x .svn ${CONFIG_DIR}

    # un-installer
    WriteUninstaller "$EXEDIR\remove-edoceo-openvpn.exe"