From 76d3dbb42f0afbd887613b8a2af03b0d0b601d43 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Mon, 30 Sep 2024 15:58:57 +0200 Subject: [PATCH] Clean files only if `VALHALLA_ROOT` is present --- scripts/Windows/OS/Manage.ps1 | 7 +++++-- scripts/Windows/Scripts/PowerManagement.ps1 | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/Windows/OS/Manage.ps1 b/scripts/Windows/OS/Manage.ps1 index e3641d12..c9dce03d 100644 --- a/scripts/Windows/OS/Manage.ps1 +++ b/scripts/Windows/OS/Manage.ps1 @@ -229,8 +229,11 @@ $null = New-Module { Remove-LocalUser $user; Get-CimInstance Win32_UserProfile | Where-Object { $_.SID -eq $sid } | Remove-CimInstance; Unregister-ScheduledTask -Confirm:$false $TaskName; - Remove-Item -Recurse -Force "$ProjectRoot"; Remove-Item -Recurse -Force "$ArtifactRoot"; + + if ($ProjectRoot) { + Remove-Item -Recurse -Force "$ProjectRoot"; + } }; $trigger = New-ScheduledTaskTrigger -AtStartup; @@ -240,7 +243,7 @@ $null = New-Module { "-Command & { $script }", (ConvertTo-Injection $taskName), (ConvertTo-Injection $setupUser), - (ConvertTo-Injection $env:VALHALLA_ROOT), + (ConvertTo-Injection "$env:VALHALLA_ROOT"), (ConvertTo-Injection (Get-ArtifactRoot)) ) -join " "); diff --git a/scripts/Windows/Scripts/PowerManagement.ps1 b/scripts/Windows/Scripts/PowerManagement.ps1 index 3121b6c9..e440578a 100644 --- a/scripts/Windows/Scripts/PowerManagement.ps1 +++ b/scripts/Windows/Scripts/PowerManagement.ps1 @@ -55,7 +55,7 @@ $null = New-Module { #> function Get-StartupCommand { ($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") + - "`$env:VALHALLA_ROOT = $(ConvertTo-Injection $env:VALHALLA_ROOT);" + + ($env:VALHALLA_ROOT ? "`$env:VALHALLA_ROOT = $(ConvertTo-Injection $env:VALHALLA_ROOT);" : "") + ($env:PWSH_PATH ? "`$env:PWSH_PATH = $(ConvertTo-Injection $env:PWSH_PATH);" : "") + ($env:BACKUP_ARCHIVE ? "`$env:BACKUP_ARCHIVE = $(ConvertTo-Injection ([System.IO.Path]::GetFullPath($env:BACKUP_ARCHIVE)));" : "") + "`$env:INSTALLER_SCRIPT = $(ConvertTo-Injection (Resolve-Path $env:INSTALLER_SCRIPT));" +