Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can one use the command-line to use openvpn on windows?

I have been trying to come up with a way to interact with openvpn on windows. I did fine the openvpn.exe but there are no commands that will use a config file to connect with a vpn server. I am using nordvpn by the way. Specifically a tcp Canadian server. I did find some people suggesting to use the openvpn-gui.exe to run the program but it defeats the purpose. I want t to completely be on command line. Secondly, i need the command line to work as i want to integrate openvopn into a script which will download stuff from the internet. Anyone with any idea how to do it?

like image 670
Hamza Avatar asked Dec 22 '25 08:12

Hamza


2 Answers

For anyone looking into this in 2021, please find below a connect and a disconnect.

To connect

"C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --command connect yourconfigfile.ovpn

To disconnect

"C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --command disconnect yourconfigfile.ovpn

For windows users... Both of these can be placed in a .bat file and automated with task scheduler, works like a charm.

like image 87
Oliver M Grech Avatar answered Dec 23 '25 22:12

Oliver M Grech


Another CMD example:

"C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --connect config.ovpn

Replace 'config.ovpn' by your configuration file. You also may have another path to openvpn-gui.exe.

It will work if you have no openVPN correctly installed so you can't run openvpn-gui ... from cmd.

like image 37
Mikhail S Avatar answered Dec 23 '25 21:12

Mikhail S