Forum Discussion
HotCakeX
Dec 02, 2020MVP
Show a notification when VPN connection disconnects on its own - built in Windows 10 connection
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 silen...
- Mar 08, 2023
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><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>