Rearrange UAC disablement

This commit is contained in:
Manuel Thalmann 2023-06-29 17:29:42 +02:00
parent 2dbd1a9fed
commit 775f6a1c10

View file

@ -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";