Clean up files after installation
This commit is contained in:
parent
1ea2c86bff
commit
68e679224f
|
@ -5,6 +5,7 @@ using namespace System.Security.Principal;
|
||||||
. "$PSScriptRoot/../Scripts/WSL.ps1";
|
. "$PSScriptRoot/../Scripts/WSL.ps1";
|
||||||
|
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
|
. "$PSScriptRoot/../Scripts/Constants.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/Deployment.ps1";
|
. "$PSScriptRoot/../Scripts/Deployment.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/Hooks.ps1";
|
. "$PSScriptRoot/../Scripts/Hooks.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
|
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
|
||||||
|
@ -218,7 +219,9 @@ $null = New-Module {
|
||||||
$script = {
|
$script = {
|
||||||
param(
|
param(
|
||||||
$TaskName,
|
$TaskName,
|
||||||
$UserName
|
$UserName,
|
||||||
|
$ProjectRoot,
|
||||||
|
$ArtifactRoot
|
||||||
)
|
)
|
||||||
|
|
||||||
$user = Get-LocalUser $UserName;
|
$user = Get-LocalUser $UserName;
|
||||||
|
@ -226,10 +229,21 @@ $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";
|
||||||
};
|
};
|
||||||
|
|
||||||
$trigger = New-ScheduledTaskTrigger -AtStartup;
|
$trigger = New-ScheduledTaskTrigger -AtStartup;
|
||||||
$task = New-ScheduledTaskAction -Execute "pwsh" -Argument "-Command & { $script } $(ConvertTo-Injection $taskName) $(ConvertTo-Injection $setupUser)";
|
|
||||||
|
$task = New-ScheduledTaskAction -Execute "pwsh" `
|
||||||
|
-Argument (@(
|
||||||
|
"-Command & { $script }",
|
||||||
|
(ConvertTo-Injection $taskName),
|
||||||
|
(ConvertTo-Injection $setupUser),
|
||||||
|
(ConvertTo-Injection $env:VALHALLA_ROOT),
|
||||||
|
(ConvertTo-Injection (Get-ArtifactRoot))
|
||||||
|
) -join " ");
|
||||||
|
|
||||||
$null = Register-ScheduledTask -Force $taskName -Action $task -Trigger $trigger -RunLevel Highest -User "SYSTEM";
|
$null = Register-ScheduledTask -Force $taskName -Action $task -Trigger $trigger -RunLevel Highest -User "SYSTEM";
|
||||||
Set-Stage ([WindowsInstallerStage]::Completed);
|
Set-Stage ([WindowsInstallerStage]::Completed);
|
||||||
Enable-UAC;
|
Enable-UAC;
|
||||||
|
|
|
@ -232,6 +232,7 @@ function Start-Setup {
|
||||||
-Script (
|
-Script (
|
||||||
"powershell -Command " +
|
"powershell -Command " +
|
||||||
($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") +
|
($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") +
|
||||||
|
"`$env:VALHALLA_ROOT = $(Get-PathInjection $env:REMOTE_PROJECT_PATH);" +
|
||||||
"`$env:PWSH_PATH = $(Get-PathInjection $env:PWSH_PATH);" +
|
"`$env:PWSH_PATH = $(Get-PathInjection $env:PWSH_PATH);" +
|
||||||
"`$env:INSTALLER_SCRIPT = $(Get-ScriptPathInjection $env:SETUP_SCRIPT_NAME);" +
|
"`$env:INSTALLER_SCRIPT = $(Get-ScriptPathInjection $env:SETUP_SCRIPT_NAME);" +
|
||||||
"`$env:CONFIG_NAME = $(ConvertTo-Injection $env:CONFIG_NAME);" +
|
"`$env:CONFIG_NAME = $(ConvertTo-Injection $env:CONFIG_NAME);" +
|
||||||
|
|
|
@ -54,8 +54,9 @@ $null = New-Module {
|
||||||
Generates a command for running the installer using `pwsh`.
|
Generates a command for running the installer using `pwsh`.
|
||||||
#>
|
#>
|
||||||
function Get-StartupCommand {
|
function Get-StartupCommand {
|
||||||
($env:PWSH_PATH ? "`$env:PWSH_PATH = $(ConvertTo-Injection $env:PWSH_PATH);" : "") +
|
|
||||||
($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") +
|
($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") +
|
||||||
|
"`$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: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));" +
|
||||||
"`$env:CONFIG_NAME = $(ConvertTo-Injection $env:CONFIG_NAME);" +
|
"`$env:CONFIG_NAME = $(ConvertTo-Injection $env:CONFIG_NAME);" +
|
||||||
|
|
Loading…
Reference in a new issue