SOLVED

Show a notification when VPN connection disconnects on its own - built in Windows 10 connection

MVP

Show a notification when VPN connection disconnects on its own - PPTP/L2TP/SSTP/IKeV2 - built in Windows 10 connection

 

There needs to be a notification when VPN connection automatically and silently disconnects on its own.

when the VPN server drops the connection or something happens to the VPN server/connection, the VPN on Windows 10 silently turns off and user is not notified, that makes us use the non-VPN connection without us knowing and causes further issue for our work.

the VPN connection I'm referring to is made through Windows 10 settings =>Network & Internet => VPN.

so please add a notification so Windows notifies us when this happens.

 

upvote this suggestion in feedback hub app: https://aka.ms/AAah9mg

 

8 Replies
For me, too, this problem is currently looking for a solution to this. It would be nice if Windows would notify us if anything happens to the VPN connection.

Me2 I agree, We all are awaiting for this fix @HotCakeX 

Please upvote the feedback in feedback hub so they will know how many people want this. thanks
best response confirmed by HotCakeX (MVP)
Solution

I fully agree this should be standard functionality in windows. But despite 3 years wait and a new OS (W11) still no joy...

I've found a workaround which works really well. I'm using task scheduler to trigger when VPN disconnects and show a messagebox.

Please find code below. Save to a XML file. In task scheduler - press import and select XML file. Change the user account to your own.

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2023-02-07T12:16:02.5177569</Date>
    <Author>vervlogen</Author>
    <URI>\VPN disconnect warning</URI>
  </RegistrationInfo>
  <Triggers>
    <EventTrigger>
      <Enabled>true</Enabled>
      <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="System"&gt;&lt;Select Path="System"&gt;*[System[Provider[@Name='Rasman'] and EventID=20268]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
    </EventTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-21-1234567890-12345678-123456789-1001</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>run-hidden</Command>
      <Arguments>powershell -WindowStyle hidden -Command "&amp; {Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::MsgBox('The VPN has disconnected','OKOnly,SystemModal,Information', 'VPN Disconnect')}"</Arguments>
    </Exec>
  </Actions>
</Task>
Thank you very much, unfortunately at the moment I'm unable to test it because I use WireGuard and OpenVPN, but I've saved your script for later!

@Vervlogen 

 

Hi Vervlogen,

 

Thank-you very much for posting your work-around notification script.

I am fundamentally computer illiterate and don't know what to change in the script to make it work

ie. "Change the user account to your own" 

 

What exactly should I change?  I've tried changing the author to my login account name but that didn't work.  Would really appreciate your help!

 

Many thanks,

 

Bleep

@Bleeping_Computer 

You need to first get your user account's SID:

(Get-CimInstance -Class win32_userAccount -Filter "name='$env:USERNAME' and domain='$env:COMPUTERNAME'").SID

And then replace the SID in this line

<UserId>S-1-5-21-1234567890-12345678-123456789-1001</UserId>

 with your own.

@HotCakeX 

 

Hi HotCakeX,

 

Many thanks for your help!

 

I've changed line 5 to my Win10 local login id

    <Author>vervlogen</Author>

 

Then, I changed line 16 to the SID for that account, which I found via PowerShell.  There were other SID's for Administrator, etc. but I used the SID which corresponds to the User Account that I used for Author.  My User Account does have Admin privileges.

 

I haven't changed anything else.  I haven't changed <Principal id="Author"> to contain my User ID as Author or any of the other Author's, yet I'm still getting an error message.

 

"An error has occurred for task Win10 VPN Disconnect.  Error Message.  One or more of he specified arguments are not valid"

 

Any ideas of what might be wrong?

 

Many thanks again,

 

Bleep

1 best response

Accepted Solutions
best response confirmed by HotCakeX (MVP)
Solution

I fully agree this should be standard functionality in windows. But despite 3 years wait and a new OS (W11) still no joy...

I've found a workaround which works really well. I'm using task scheduler to trigger when VPN disconnects and show a messagebox.

Please find code below. Save to a XML file. In task scheduler - press import and select XML file. Change the user account to your own.

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2023-02-07T12:16:02.5177569</Date>
    <Author>vervlogen</Author>
    <URI>\VPN disconnect warning</URI>
  </RegistrationInfo>
  <Triggers>
    <EventTrigger>
      <Enabled>true</Enabled>
      <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="System"&gt;&lt;Select Path="System"&gt;*[System[Provider[@Name='Rasman'] and EventID=20268]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
    </EventTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-21-1234567890-12345678-123456789-1001</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>run-hidden</Command>
      <Arguments>powershell -WindowStyle hidden -Command "&amp; {Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::MsgBox('The VPN has disconnected','OKOnly,SystemModal,Information', 'VPN Disconnect')}"</Arguments>
    </Exec>
  </Actions>
</Task>

View solution in original post