Scenario / Questions

On windows server 2008,2012 or above I need to re-connect VPN automatically once it is disconnected due to any reason.

It may be server restart, Manual command to Disconnect. Persistent VPN connection.

Any work arounds

Find below all possible solutions or suggestions for the above questions..

Suggestion: 1

I sort it out using “Task Scheduler”

Here are steps to do it

  1. Make VPN Connection and give it Some Name Let say “My VPN”

  2. Open “Task Scheduler” from Start Menu and click “Create Task” (Option can be found on right side of Task Scheduler)

  3. POPUP will appear asking for Task Information. Fill in information like below Task Info

  4. After that go to Trigger Tab and Select “New”. Another POPup will appear like below New Trigger

  5. On Top Select “Begin The Task” Drop Down Menu and choose “On an Event”

  6. Below List will change In “Log:” Choose “Application”, In “Source:” choose “RasClient”, In “EventID:” choose “20226” and then click OK like below
    Event Trigger

  7. Again click on “New” and add another Trigger. On Top again Select “Begin The Task” Drop Down Menu and choose “On an Event” then In “Log:” Choose “Microsoft-Windows-NetworkProfile/Operational”, In “Source:” choose “NetworkProfile”, In “EventID:” choose “10000” and then click OK like below
    Network Trigger

  8. This will add two triggers for our Tasks. like below Triggers List

  9. Now we will Add action. Click on Next Tab named “Action” and then Click New, Another Popup will appear. In “Action:” it should be Start a Program then In “Program/Script:” Click Browse and Choose rasdial.exe Its path will appear as it is present inside “System32” folder.Now you need to add name of VPN and credentials in “Add arguments (optional)” in following order

    “VPN Name” username passwordAction

  10. Now click OK and Create Task It will appear Tasks List. Now go to VPN Connection Disconnect it and you will see it reconnects automatically. Restart the server and you will see VPN Connected By Default.

Suggestion: 2

In case you are lazy you can import this into the task scheduler. Just edit the action with your own vpn details and save as XML.

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="">
    <URI>reconnect vpn</URI>
      <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Application"&gt;&lt;Select Path="Application"&gt;*[System[Provider[@Name='RasClient'] and EventID=20226]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
      <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Microsoft-Windows-NetworkProfile/Operational"&gt;&lt;Select Path="Microsoft-Windows-NetworkProfile/Operational"&gt;*[System[Provider[@Name='NetworkProfile'] and EventID=10000]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
  <Actions Context="Author">
      <Arguments>"MyVPN Name" user password</Arguments>

Suggestion: 3

I have experienced this problem. I close all apps and reboot. I will get a green screen scan page for < I minute. In Control Panel>Networks>change adapter settings, I manually enable the main cable. After that all is well.