How to automate OpenVPN connections?

Post Reply
OpenVPN Power User
Posts: 128
Joined: Mon May 05, 2014 10:17 pm

How to automate OpenVPN connections?

Post by BobAGI » Fri Aug 11, 2017 6:21 am

I have a couple of servers running OpenVPN at different locations so I can access these networks via the Internet.
These servers all run Linux.
It works fine to manually connect with OpenVPN from my Windows7 computer.

Now I want to upgrade a few administrative scripts that run maintenance on the remote servers using the Windows PPTP VPN (which is also installed on these servers) so that the connection uses OpenVpn instead.
How can I make OpenVPN connect and disconnect a tunnel on command from a batch file in Windows 7?

My maintenance system works as follows from inside a batch file, which is run by Task Scheduler at a set time in the middle of the night:
1) Open VPN tunnel to remote site
2) Connect to the proper local service on the remote site
3) Execute the maintenance commands and wait for them to complete
4) Log actions locally as verification
5) Disconnect the VPN tunnel

The VPN used for this is Windows PPTP VPN and I really want to increase the security over Internet by using OpenVPN instead.

Note that I do not want the VPN tunnel to be constantly on, it should be established at start of the session and disconnected at the end.

How can this be accomplished?
The target systems are Linux boxes and the main system running the tasks is a Windows 7 PC.

User avatar
OpenVPN Protagonist
Posts: 4632
Joined: Fri Jun 03, 2016 1:17 pm

Re: How to automate OpenVPN connections?

Post by TinCanTech » Fri Aug 11, 2017 10:33 am

Post Reply