1

Currently, I have the OpenVPN windows service set up, and it runs well. I wanted to know if there was a way to make it connect to the VPN whenever I am not connected to my home network (connected to any other network besides my home's).

Whenever I am on my home network I do not want to use the VPN because it is not necessary, but then if I disconnect from my home's Wi-Fi and connect to a different network, I want to also be automatically connected to my VPN.

I was looking in the windows services GUI and I saw some properties of the services called "Start parameters" and thought that that might be what I need to use.


The command used to start the service from the command line is:

"C:\Program Files\OpenVPN Connect\ovpnconnector.exe" start

(The OpenVPN server I am connecting to is run off of a computer at home)

3

1 Answer 1

2

I need to log, but take a look at running Scheduled Tasks on a hardware event similar to superuser.com/questions/219401/… – spikey_richie

It worked! In the task scheduler, I made one task that starts the OpenVPN service each time I connect to the internet, and another that stops the service whenever I connect to my home's Wi-Fi network.

Task scheduler config #1 (General)
Task scheduler config #1 (Edit Triggers)
Task scheduler config #1 (Actions)
Task scheduler config #1 (Conditions)

Task scheduler config #2 (General)
Task scheduler config #2 (Edit Triggers)
Task scheduler config #2 (Actions)
Task scheduler config #2 (Conditions)

Edit: I changed the action on the connection script to C:\WINDOWS\system32\cmd.exe /C ping -w 5 -n 1 attlocal.net || ping -w 2 -n 5 10.8.0.1 || ovpnconnector.exe start and it seems to work better (this new action checks to see if it can ping my home router, then if it can ping my OpenVPN server, and finally connects to the VPN if it can't do either of those things).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .