If you wish to have OpenVPN automatically start up and log in to a default connection when you boot your computer, follow the steps below. You must be using the latest version of OpenVPN 2.3 or above for this to work. Also, using this method saves your user name and password in a text file on your computer. You should only do this on a computer that is secure and never on a public or shared machine.
In the search bar, enter ‘regedit’ and it will find regedit.exe. Launch it. Be very careful using regedit and make no changes to other settings, as it can break your computer.
Browse to the following location:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
Click on ‘Edit’
Click on ‘New’
Click on ‘String Value’
Name the string something descriptive such as ‘VPN’
Now click on ‘Edit and Modify’
Add the following line to the new string you created:
For 32 bit Windows – “C:\Program Files\OpenVPN\bin\openvpn-gui.exe” –connect xxxxx.ovpn
For 64 bit Windows – “C:\Program Files (x86)\OpenVPN\bin\openvpn-gui.exe” –connect xxxxx.ovpn
The xxxxx is replaced with the name of the OpenVPN configuration file you wish to start. Your list of available .ovpn files can be found in the ‘OpenVPN/config’ folder on your computer. Or, you can use the names from your connection pick list by typing them exactly as shown and adding ‘.ovpn’ to the end.
For example, the pick list ‘USA East’ would be entered as ‘USA East.ovpn’
Exit regedit
Now you need to create the password file:
Open NotePad by right-clicking and selecting ‘Run as Administrator’
Type in your user name and press enter then type in your password. Be sure there are no blank spaces on either line.
Save the file to:
(For 32 bit OpenVPN users):
C – Program Files (x86) – OpenVPN – config
(For 64 bit OpenVPN users):
C – Program Files – OpenVPN – config
Next, in the login menu, right-click on the connection you added in the registry as your default. Select ‘Edit Config’
Find the line that reads ‘auth-user-pass’
Change it to ‘auth-user-pass password.txt’. (note that it is a space, not a hyphen, between the words ‘pass’ and ‘password’)
Save and exit
You can also change this line on all of your other configurations files and they will automatically log in without having to enter a user password in the future.
Now when you reboot the computer, OpenVPN will automatically start and log you in to your default connection.