Automatically ROUTE ADD xxxx after i make a VPN connection in Windows 7

site-to-site-vpnvpnwindows 7

after I make a VPN connection to my work/whatever, I currently have to go into the command prompt and manually add a route.

eg.

ROUTE ADD 10.1.0.0 255.255.0.0 172.16.3.0 METRIC 1 or whatever the command is.

Is it possible to have this automatically happen after I successfully make a VPN connection?

Best Answer

If you want to make it a 1-step process, you could create a batch file that runs rasdial to automate your VPN connection and then does a ROUTE ADD:

rasdial "connection name" username password ('*' to prompt for password)
ROUTE ADD 10.1.0.0 255.255.0.0 172.16.3.0 

This assumes you're connecting to a Microsoft VPN, but you could script the OpenVPN client in the same way:

openvpn c:\path\to\config-file.ovpn
ROUTE ADD 10.1.0.0 255.255.0.0 172.16.3.0