From f58b7895e48acfed67e0524f1c5917b0e2000d04 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sun, 24 Mar 2024 18:16:29 +0100 Subject: [PATCH] Move cleanup scripts to proper location --- scripts/Windows/OS/User/Add.ps1 | 2 +- scripts/Windows/OS/User/AutoLogin.ps1 | 4 ++++ scripts/Windows/OS/User/UACDisabler.ps1 | 7 ++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/Windows/OS/User/Add.ps1 b/scripts/Windows/OS/User/Add.ps1 index 974d1529..8daf925b 100644 --- a/scripts/Windows/OS/User/Add.ps1 +++ b/scripts/Windows/OS/User/Add.ps1 @@ -74,9 +74,9 @@ function New-PersonalUser([Context] $context, [string] $userName) } $postProcessStage { Enable-PersonalUserAutologon $context $userName; - $context.RegisterReboot(); Set-UserStage $adminRemovalStage; Start-EventDrivenTask $context.Get($uacDisablerTriggerProperty); + $context.Reboot(); exit; } $adminRemovalStage { diff --git a/scripts/Windows/OS/User/AutoLogin.ps1 b/scripts/Windows/OS/User/AutoLogin.ps1 index 780fb130..f6970ede 100644 --- a/scripts/Windows/OS/User/AutoLogin.ps1 +++ b/scripts/Windows/OS/User/AutoLogin.ps1 @@ -10,4 +10,8 @@ $context = [Context]::new(); $userName = $context.Get($PreparedUsernameProperty); $password = $context.Get($PreparedSecretProperty); $context.SetAutologin($userName, $password); +$context.Remove($PreparedUsernameProperty); +$context.Remove($PreparedSecretProperty); +Unregister-ScheduledTask -Confirm:$false $AutoLoginTaskName; Write-EventLog -LogName Application -Source "Application" -EventId $EventID -Message "This event was created by $env:Username"; +$context.Remove($AutoLoginTriggerProperty); diff --git a/scripts/Windows/OS/User/UACDisabler.ps1 b/scripts/Windows/OS/User/UACDisabler.ps1 index fce7b677..172f5cf6 100644 --- a/scripts/Windows/OS/User/UACDisabler.ps1 +++ b/scripts/Windows/OS/User/UACDisabler.ps1 @@ -9,11 +9,8 @@ param ( . "$PSScriptRoot/../../Scripts/Context.ps1"; $context = [Context]::new(); -Unregister-ScheduledTask -Confirm:$false $AutoLoginTaskName; -Unregister-ScheduledTask -Confirm:$false $UACDisablerTaskName; $context.SetUACState($false); -$context.Remove($AutoLoginTriggerProperty); +Unregister-ScheduledTask -Confirm:$false $UACDisablerTaskName; +Write-EventLog -LogName Application -Source "Application" -EventId $EventID -Message "This event was created by $env:Username"; $context.Remove($UACDisablerTriggerProperty); $context.DeregisterNewUserReboot(); -Write-EventLog -LogName Application -Source "Application" -EventId $EventID -Message "This event was created by $env:Username"; -Restart-Computer -Force; \ No newline at end of file