# Can I automatically ROUTE ADD xxxx after i make a VPN connection in Windows 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?

-

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)


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

You could make the route persistent (I think with route -p) so you don't need to enter it each time. If you are using openVPN, the server can send a route to the client: push "route 192.168.1.0 255.255.255.0" for example. With other VPNs servers I dont' know but I guess they may have a similar option too.