From 775f6a1c1016ece92f70ebd0c001fb2b4f894980 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 29 Jun 2023 17:29:42 +0200 Subject: [PATCH] Rearrange UAC disablement --- scripts/Windows/OS/User.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/Windows/OS/User.ps1 b/scripts/Windows/OS/User.ps1 index f563519b..d57682b0 100644 --- a/scripts/Windows/OS/User.ps1 +++ b/scripts/Windows/OS/User.ps1 @@ -50,6 +50,7 @@ function New-PersonalUser([Context] $context) Enable-CurrentUserAutologon $context; Write-Information "Removing Admin Account"; Get-CimInstance -ClassName "Win32_UserProfile" -Filter "SID = $((Get-LocalUser $context.AdminName).SID)" | Remove-CimInstance; + $context.RegisterReboot(); Write-EventLog -LogName Application -Source "Application" -EventId $taskTrigger -Message "This event was created by $env:Username"; exit; } @@ -84,8 +85,7 @@ function Enable-UACNextLogin([Context] $context) { "Unregister-ScheduledTask -Confirm:`$false '$uacDisablerName';", ". '$PSScriptRoot/../Scripts/Context.ps1';", "`$context = [Context]::new();", - "`$context.EntryPoint = '$($context.EntryPoint)';", - "`$context.RegisterReboot((Get-Item 'Registry::HKEY_USERS\$((Get-LocalUser $context.UserName).SID)'));", + "`$context.DeregisterNewUserReboot();", "Restart-Computer -Force;"))); schtasks /Create /SC ONEVENT /EC Application /MO "*[System[Provider[@Name='Application'] and EventID=$taskTrigger]]" /TR cmd.exe /TN "$tempTask";