How to reconnect VPN automatically after sleep/hibernate on Vista/7?
I'm using Win 7's built-in VPN client but every time I put my computer to sleep / hibernate mode and then wake it up again, the connection is lost and I need to reconnect manually. Is there any way to automate it? Wireless connections have a nice little checkbox ("automatically connect when this network is in range") but I couldn't find anything similar for VPN connections. Task scheduler maybe?
Solution 1:
Okay I had the same exact "problem", do like this (translated). Make a scheduled event with the following options:
Set triggers:
- When connected to a user session (or similar), At login and When unlocking workstation.
- Certain user [yourcomputer\username] (optional but recommended)
- Connection from the local computer
- Activated
Set actions:
- Start a program
- Program or script: rasdial
- Argument: "the VPN Connection name" your_username your_password (with quotes)
If you would like extra security skip entering the password in the previous step. This is however only a bit insecure if someone else is sitting at your computer and opens up this dialog they can see your login detail.. You will however then always have to enter the password manually (I'm not sure if a dialog shows up though but it might).
Edit: Seems like this only works for when you use "switch user". I've added Triggers: "At login" and "When unlocking the workstation". Hopefully this covers all possible scenarios. I've also added a 30 second delay on Switch user and At Login so it doesn't try before there is a network connection available.