Clean files only if VALHALLA_ROOT is present

This commit is contained in:
Manuel Thalmann 2024-09-30 15:58:57 +02:00
parent c5762ca86f
commit 76d3dbb42f
2 changed files with 6 additions and 3 deletions

View file

@ -229,8 +229,11 @@ $null = New-Module {
Remove-LocalUser $user; Remove-LocalUser $user;
Get-CimInstance Win32_UserProfile | Where-Object { $_.SID -eq $sid } | Remove-CimInstance; Get-CimInstance Win32_UserProfile | Where-Object { $_.SID -eq $sid } | Remove-CimInstance;
Unregister-ScheduledTask -Confirm:$false $TaskName; Unregister-ScheduledTask -Confirm:$false $TaskName;
Remove-Item -Recurse -Force "$ProjectRoot";
Remove-Item -Recurse -Force "$ArtifactRoot"; Remove-Item -Recurse -Force "$ArtifactRoot";
if ($ProjectRoot) {
Remove-Item -Recurse -Force "$ProjectRoot";
}
}; };
$trigger = New-ScheduledTaskTrigger -AtStartup; $trigger = New-ScheduledTaskTrigger -AtStartup;
@ -240,7 +243,7 @@ $null = New-Module {
"-Command & { $script }", "-Command & { $script }",
(ConvertTo-Injection $taskName), (ConvertTo-Injection $taskName),
(ConvertTo-Injection $setupUser), (ConvertTo-Injection $setupUser),
(ConvertTo-Injection $env:VALHALLA_ROOT), (ConvertTo-Injection "$env:VALHALLA_ROOT"),
(ConvertTo-Injection (Get-ArtifactRoot)) (ConvertTo-Injection (Get-ArtifactRoot))
) -join " "); ) -join " ");

View file

@ -55,7 +55,7 @@ $null = New-Module {
#> #>
function Get-StartupCommand { function Get-StartupCommand {
($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") + ($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: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:BACKUP_ARCHIVE ? "`$env:BACKUP_ARCHIVE = $(ConvertTo-Injection ([System.IO.Path]::GetFullPath($env:BACKUP_ARCHIVE)));" : "") +
"`$env:INSTALLER_SCRIPT = $(ConvertTo-Injection (Resolve-Path $env:INSTALLER_SCRIPT));" + "`$env:INSTALLER_SCRIPT = $(ConvertTo-Injection (Resolve-Path $env:INSTALLER_SCRIPT));" +