4
I use a VPN to connect to the office from home. I use Windows XP's built-in VPN support for this.
Due to some unfortunate subnet choices, I must run a script to set up some network routes every time the VPN connection has been established. At present, this is a batch file that invokes a PHP CLI script.
The VPN connection is limited to 12 hour sessions; Windows will automatically re-establish the connection, but how can I tell it to invoke my routes script once it's done so?
(If I don't, some buggy software I use leaks file descriptors like nobody's business as it keeps trying to re-establish the connection, and sometimes this causes problems for me: if the machine is unattended, networking becomes unusable after a few hours and I have to reboot, rather than my preference of hibernating all the time.)
FWIW I eventually found a way to do this. However: (a) it may have been only after migration to Windows 7, I don't recall; I did certainly have it working on 7, and (b) it was on a work laptop to which I no longer have access. Probably not a lot of point holding on to this question now. – Lightness Races with Monica – 2018-08-08T13:00:06.227
Why not setup a scheduled task to run every few minutes just grab the output of
route
. If your static routes don't exist, but the VPN link is up, then add the routes. BTW have you tried passing the-p
option to route to setup a persistent route? – Zoredache – 2011-09-21T22:18:13.633@Zoredache: The gateway changes each time I connect to the VPN so I don't think that persistent routes will help. A scheduled task might do it but then there's potentially a small delay between VPN connectivity and establishing routes, which would be irritating were I working at the time. – Lightness Races with Monica – 2011-09-22T09:25:31.373