Dec 02 2020 02:40 AM
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
Aug 17 2021 05:02 AM
Sep 02 2021 05:01 AM
Me2 I agree, We all are awaiting for this fix @HotCakeX
Sep 05 2021 11:24 PM
Mar 08 2023 05:13 AM
SolutionI 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><QueryList><Query Id="0" Path="System"><Select Path="System">*[System[Provider[@Name='Rasman'] and EventID=20268]]</Select></Query></QueryList></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 "& {Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::MsgBox('The VPN has disconnected','OKOnly,SystemModal,Information', 'VPN Disconnect')}"</Arguments>
</Exec>
</Actions>
</Task>
Mar 08 2023 08:41 AM
Sep 04 2023 12:41 PM
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
Sep 04 2023 10:29 PM
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.
Sep 05 2023 06:54 AM
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
Mar 08 2023 05:13 AM
SolutionI 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><QueryList><Query Id="0" Path="System"><Select Path="System">*[System[Provider[@Name='Rasman'] and EventID=20268]]</Select></Query></QueryList></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 "& {Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::MsgBox('The VPN has disconnected','OKOnly,SystemModal,Information', 'VPN Disconnect')}"</Arguments>
</Exec>
</Actions>
</Task>