From d78565e1a66a715b18da36ad4b0348501374caba Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 10 Aug 2024 15:24:04 +0200 Subject: [PATCH] Add a function for removing the `RunOnce` key --- scripts/Windows/Scripts/PowerManagement.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/Windows/Scripts/PowerManagement.ps1 b/scripts/Windows/Scripts/PowerManagement.ps1 index 5f4a6226..6dc26435 100644 --- a/scripts/Windows/Scripts/PowerManagement.ps1 +++ b/scripts/Windows/Scripts/PowerManagement.ps1 @@ -96,6 +96,21 @@ $null = New-Module { $key.Handle.Close(); } + <# + .SYNOPSIS + Clears leftovers from past registrations. + #> + function Clear-SetupRegistration { + Edit-DefaultUserKey { + param( + [RegistryKey] $Key + ) + + $runOnceKey = Get-RunOnceKey $Key; + Remove-Item $runOnceKey.PSPath; + } + } + <# .SYNOPSIS Sets the user to login automatically on boot.