Solution for "The system cannot find the file specified" error when connecting to VPN on Windows

Solution for "The system cannot find the file specified" error when connecting to VPN on Windows

All credit goes to MrModaeus and his answer on Reddit

This post is intended to hopefully make it more discoverable in Google searches for anyone else with the same problem.

Long story short the error "The system cannot find the file specified" when trying to connect to VPN is caused by a corrupt or missing registry.

Just run code bellow in administrator PowerShell console to fix this:

# Create missing registry key
New-Item -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters -Name DnsPolicyConfig

# Configure permissions on key for "NT Authority\DNSCache"
$keyPath = 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DnsPolicyConfig'
$acl = Get-Acl -Path $keyPath

$idRef = [System.Security.Principal.NTAccount]("NT SERVICE\Dnscache")
$regRights = [System.Security.AccessControl.RegistryRights]::FullControl
$inhFlags = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit
$prFlags = [System.Security.AccessControl.PropagationFlags]::None
$acType = [System.Security.AccessControl.AccessControlType]::Allow
$rule = New-Object System.Security.AccessControl.RegistryAccessRule ($idRef, $regRights, $inhFlags, $prFlags, $acType)

$acl.AddAccessRule($rule)
$acl.SetAccessRule($rule)
$acl | Set-Acl -Path $keyPath

In case 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DnsPolicyConfig' already exists and fix didn't help, try to export it (just in case), delete it and ruh the PS code again.