Windows – How to automate turning on/off Windows VPN connection

scheduled-taskvpnwindows

I want to automate VPN connection to come ON nightly so that a database can replicate, then I would like to have it turned off. I know how to schedule Tasks, but is there a command line interface for the VPN connections? or how to turn this on/off?

Best Answer

It's a little bit of a process, but yes it can be done.

Create a VPN connection, save the username and password. Save the username and password. Disable the requirement to display progrss while connecting. Disable the "Prompt for name and password, certificate, etc".

Create a shortcut to the network connection. Save it somewhere handy. Create a batch file which simply has the name of the .lnk file in it. If the .lnk file is called "corp_vpn.lnk" the file should look like:

corp_vpn.lnk

Then have it mirror the data.

To disconnect automatically, set the idle timeout (probably set it nice and high) and it'll connect and disconnect as needed.

Related Topic