Automatic OpenVPN Client Connection at Windows Startup
Many users want their OpenVPN connection to start automatically when the computer boots. Although OpenVPN for Windows does not have a built-in option for this, it can be configured manually.
Startup command
Use the following startup command to automatically connect to a specific .ovpn
configuration file:
- Windows 32 bit:
"C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --connect xxxxx.ovpn
- Windows 64 bit:
"C:\Program Files (x86)\OpenVPN\bin\openvpn-gui.exe" --connect xxxxx.ovpn
Replace xxxxx.ovpn
with the actual configuration file name located in the OpenVPN/config
folder.
Registry configuration
- Open
regedit
. - Navigate to:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
- Add a new string entry (e.g., openvpn).
- Paste the startup command as its value.
Important notes
- If Windows is not installed on
C:
or OpenVPN is installed in a different folder, update the path accordingly. - On Windows Vista, 7, and 8, OpenVPN-GUI must be run as Administrator. You can set this under Properties → Compatibility → Run as administrator.
Automatic login with username and password
By default, OpenVPN will prompt for credentials at startup. To automate this, you can save your login details in a text file (note: this is insecure). Recent versions of OpenVPN allow secure credential storage within the app; use this manual method only for older versions.
- Create a
password.txt
file in theOpenVPN/config
folder with:
Line 1 → username
Line 2 → password - Edit your
.ovpn
file and changeauth-user-pass
toauth-user-pass password.txt
. - Install OpenVPN version 2.3 or later if your build does not support this feature.