Pages

Followers

AutoRedial for VPN Connections in Windows

AutoRedial for VPN Connections in Windows 8/10 & server 2012

I was surprised, not much, however, when I found that in Windows 8 and Windows Server 2008 or higher Microsoft had slightly “refined” the VPN connection settings. To be more precise, removed a number of settings in the Options tab. Here is what it looked like in Windows 7:
Now(Windows 8, Windows 10) almost everything has been removed:
A natural question has arised — how to configure automatic reconnection and the number of attempts to establish the connection if it is interrupted?
There are several ways to do it. Let’s start with the beginning, according to the level of difficulty.

Method 1 — Using Notepad
You have to set the parameters manually. To do it, go to the folder
C:Users[USER]AppDataRoamingMicrosoftNetworkConnectionsPbk
There, find a file (it is likely to be only one) with the name rasphone.pbk. It is a usual text file, which contains the VPN connection settings
You can open this file using notepad.exe
Usually you have to find a section containing your VPN, e. g., like this [PPTP-VPN]
Find the lines in it. If you haven’t made any changes, they look like this:
RedialAttempts=3
RedialSeconds=60
IdleDisconnectSeconds=0
RedialOnLinkFailure=1
So Microsoft has decided it for you again.
But now you know where to find and change the necessary parameters.
  • RedialAttempts=3                 – the number of redial attempts (99 maximum)
  • RedialSeconds=60                 – the number of seconds between the redial attempts
  • IdleDisconnectSeconds=0     — the waiting time before it becomes clear that there is a disconnection (0 – don’t wait)
  • RedialOnLinkFailure=1         — Redial if connection fails? 1 – yes, 0 – no
To apply the parameters, you have to restart your VPN connection, as earlier.
And then believe that Microsoft will do everything for you
Note. It has been noticed that Windows Server 2012 can use C:Users[USER]AppDataRoamingMicrosoftNetworkConnectionsPbk\_hiddenPbk folder on its own initiative and locate rasphone.pbk in this folder.
Method 2 — Configuration of a Simple Task
Create a task in Task Scheduler, which will run a BAT file containing the VPN connection string and configure this task so that it runs, say, every 5 minutes.
I should remind that the command string to establish a VPN connection looks like this:
C:windowssystem32 asdial.EXE entryname [username [password|*]] [/DOMAIN:domain]
There are other parameters, but if it is interesting to you find them yourself.
Don’t forget to check “Run whether user is logged on or not” in the task settings
Specify the executable file, for example:
Or let rasdial.exe start (VPN User Password is the name of your VPN connection, user_name and password)

Start it every 5 minutes every day.
Method 3 — Configure a Tricky Task
  1. Create a task in Task Scheduler
  2. Set two triggers in the task. The first one will use an XML query (like it has been described in the article “How to Start a Scheduler Task After the Previous Task“)


Note. Values: 829 — Remote Disconnect, 629 -Client Disconnect
The second trigger is based on tracking of the event in the Event Log:
  • Log name: Microsoft-Windows-NetworkProfile/Operational
  • Source: NetworkProfile
  • Event ID: 10000
  • Select rasdial.exe with the parameters vpn-name username password as a program to be started
  • Also, in the Conditions tab, you can check the following parameters:
Note. To make sure if this task works, create another trigger with the Event ID = 10001. This event appears when VPN is disconnected manually. After that, try to disconnect the VPN manually. The connection will be restored immediately.
That’s all.

Note. The methods described above are also applicable to Windows 7