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));" +