Windows OS Hub
  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange

 Windows OS Hub / Windows 10 / AutoRedial for VPN Connections in Windows 8/10/2012

May 5, 2016 Windows 10Windows 8Windows Server 2012

AutoRedial for VPN Connections in Windows 8/10/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:

VPN conection option in Windows 7

Now(Windows 8, Windows 10) almost everything has been removed:

VPN option tab Windows 8 / Windows 2012

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]\AppData\Roaming\Microsoft\Network\Connections\Pbk\

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]\AppData\Roaming\Microsoft\Network\Connections\Pbk\_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:\windows\system32\rasdial.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

VPN Redial task

Specify the executable file, for example:

rasdial.bat

Or let rasdial.exe start (VPN User Password is the name of your VPN connection, user_name and password)

rasdial.exe vpn connection

Start it every 5 minutes every day.

repeat task every 5 minutes

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“)

<QueryList>
<Query Id="0" Path="Application">
<Select Path="Application">*[System[Provider[@Name='RasClient'] and (EventID=20226)]] and *[EventData[Data[4]='829' or '629']]</Select>
</Query>
</QueryList>

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:

vpn task settings

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

1 comment
0
Facebook Twitter Google + Pinterest
previous post
Disable Outlook Mailbox Auto-Mapping in Exchange
next post
Configuring Remote Control in SCCM 2012

Related Reading

How to Troubleshoot, Repair and Rebuild the WMI...

March 2, 2021

How to Sign a PowerShell Script (PS1) with...

February 25, 2021

How to Shadow (Remote Control) a User’s RDP...

February 22, 2021

Configuring PowerShell Script Execution Policy

February 18, 2021

Configuring Proxy Settings on Windows Using Group Policy...

February 17, 2021

1 comment

George January 25, 2018 - 8:14 pm

Thanks SO much for this guide. After upgrading from W7 to W10, this was bugging the hell out of me. Thank to this, I was even able to create a “VPN Alternate” task, which looks for an 809 Error Code (ERROR_VPN_TIMEOUT aka VPN server unresponsive) in the Event Log and then dial an alternate VPN server. I simply created the same Tricky Task as above, but edited this line of the XML query:
*[EventData[Data[4]=’829′ or ‘629’]]

…to this:
*[EventData[Data[4]=’809′]]

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange
  • Windows 10
  • Windows 8
  • Windows 7
  • Windows Server 2016
  • Windows Server 2012 R2
  • Windows Server 2008 R2
  • PowerShell
  • VMWare
  • MS Office

Recent Posts

  • How to Troubleshoot, Repair and Rebuild the WMI Repository?

    March 2, 2021
  • Accessing USB Flash Drive from VMWare ESXi

    February 26, 2021
  • How to Sign a PowerShell Script (PS1) with a Code Signing Certificate?

    February 25, 2021
  • Change the Default Port Number (TCP/1433) for a MS SQL Server Instance

    February 24, 2021
  • How to Shadow (Remote Control) a User’s RDP session on RDS Windows Server 2016/2019?

    February 22, 2021
  • Configuring PowerShell Script Execution Policy

    February 18, 2021
  • Configuring Proxy Settings on Windows Using Group Policy Preferences

    February 17, 2021
  • Updating Group Policy Settings on Windows Domain Computers

    February 16, 2021
  • Managing Administrative Shares (Admin$, IPC$, C$, D$) in Windows 10

    February 11, 2021
  • Packet Monitor (PktMon) – Built-in Packet Sniffer in Windows 10

    February 10, 2021

Follow us

woshub.com
  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Unable to Connect Windows 10 Shared Printer to Windows XP
  • How to Restore Windows Photo Viewer in Windows 10
  • How to Remove Unused Drivers from Driver Store
  • How to Configure a Slideshow Screensaver Using GPO
  • Windows 10: WSUS Error 0x8024401c
  • Restore Missing CD/DVD Drive in Windows 10
  • This App Has Been Blocked for Your Protection : Windows 10
Footer Logo

@2014 - 2018 - Windows OS Hub. All about operating systems for sysadmins


Back To Top