Skip to content

Instantly share code, notes, and snippets.

@robert-werner
Last active March 30, 2025 10:43
Show Gist options
  • Save robert-werner/ef67bf40199e9d7561963594e5b87367 to your computer and use it in GitHub Desktop.
Save robert-werner/ef67bf40199e9d7561963594e5b87367 to your computer and use it in GitHub Desktop.
Wireguard "Access Denied" fix on Windows 10+
$rule = New-Object System.Security.AccessControl.RegistryAccessRule(
"NT AUTHORITY\NETWORK SERVICE", # IdentityReference
[System.Security.AccessControl.RegistryRights]::FullControl, # RegistryRights
[System.Security.AccessControl.InheritanceFlags]::ContainerInherit, # InheritanceFlags
[System.Security.AccessControl.PropagationFlags]::None, # PropagationFlags
[System.Security.AccessControl.AccessControlType]::Allow # AccessControlType
)
$registry_keys = "Dhcp", "Tcpip", "Tcpip6", "TCPIPTUNNEL", "TCPIP6TUNNEL"
$registry_folder = "HKLM:\SYSTEM\CurrentControlSet\Services\{registry_key}"
foreach ($registry_key in $registry_keys)
{
$full_registry_key = $registry_folder.Replace("{registry_key}", $registry_key)
$acl = Get-Acl $full_registry_key
$acl.AddAccessRule($rule)
Set-Acl -Path $full_registry_key -AclObject $acl
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment