Discussion:
[Openvpn-users] Initiating connection at boot time
David Arnstein
2017-02-20 03:28:08 UTC
Permalink
I have openvpn installed with a single client configuration in
Windows 10 Home. I see that I have a service "OpenVPN Interactive
Service" that starts automatically.

What I would like to do is connect to my OpenVPN server *at boot
time.* Not at login time.

I tried the obvious thing and added a call to registry key
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run which launches
openvpn-gui-exe with an argument --connect (my configfile).

This does launch the program openvpn-gui.exe, but no connection
occurs. The error I found in Windows event log is
openvpnserv error:
0x20000000
OpenVPN exited with error: exit code = 1073807364

Another time, I rebooted the PC and I could find nothing in the event
log.

Any suggestions?
Selva Nair
2017-02-20 05:00:19 UTC
Permalink
Post by David Arnstein
I have openvpn installed with a single client configuration in
Windows 10 Home. I see that I have a service "OpenVPN Interactive
Service" that starts automatically.
What I would like to do is connect to my OpenVPN server *at boot
time.* Not at login time.
I tried the obvious thing and added a call to registry key
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run which launches
openvpn-gui-exe with an argument --connect (my configfile).
This does launch the program openvpn-gui.exe, but no connection
occurs. The error I found in Windows event log is
0x20000000
OpenVPN exited with error: exit code = 1073807364
That's too cryptic. Have you looked inot openvpn's log to find what could
have gone wrong. As this is being started by the GUI, The log will be in
the directory OpenVPN\log under the user's profile.

That said adding the gui to HKLM\...\Run will not achieve what you are
trying to do. Programs added to the "Run" key are started when a user logs
in, not at boot time. And adding it to HKLM it applies to all users and
will cause it to start again if you switch users.

Now, an interactive program like the GUI cannot be run before any user logs
in. I can suggest two ways to achieve what you want:

(i) Do not use the GUI. Instead run openvpnservice which will automatically
start all configs in C:\Program Files\OpenVPN\config at boot time (the
default path for configs will be different if openvpn is installed
elsewhere and may be changed by editing the registry as well). But such
connections cannot be controlled by OpenVPN-GUI. Usually there is no need
to interact with a connection started at boot time -- if needed there are
other GUIs like the MI-GUI which can control such persistent connections.

Note that this service is different from the interactive service. Its
installed by default but not set to start automatically.

(ii) If you must manipulate the connection using openvpn-gui, here is a
hackish approach: Use autologon from sysinternals[1] and set it to
automatically login a user at boot time. Then setup a scheduled task for
the same user to run "openvpn-gui.exe --connect <config>" followed by
locking the screen[2]. The task should be to set to trigger at login. Then
the connection will automatically start soon after boot and the GUI will be
available if/when you unlock the screen or connect to the machine by remote
desktop. I haven't tried this with openvpn so I can only say its ought to
work.

Selva

[1] https://technet.microsoft.com/en-us/sysinternals/autologon.aspx
[2] Something like rundll32.exe user32.dll,LockWorkStation

Loading...