From 379c081144ac664b3b6b17671a4cd89b15fc7d47 Mon Sep 17 00:00:00 2001
From: "Kenneth Benzie (Benie)" <benie@infektor.net>
Date: Fri, 9 Aug 2024 17:35:49 +0100
Subject: [PATCH] Add self-removal to bootstrap-Windows.ps1

---
 bootstrap-Windows.ps1 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bootstrap-Windows.ps1 b/bootstrap-Windows.ps1
index eaa6823..a6c5325 100644
--- a/bootstrap-Windows.ps1
+++ b/bootstrap-Windows.ps1
@@ -11,11 +11,16 @@ if (-Not $IsElevated) {
   Invoke-WebRequest -Uri https://get.scoop.sh -OutFile $ScoopInstaller
   &$ScoopInstaller -ScoopDir "$env:LocalAppData/Scoop" -ScoopGlobalDir "$env:ProgramData/Scoop"
 
+  $Bootstrap = $MyInvocation.MyCommand.Path
   $Decision = $Host.UI.PromptForChoice('Relaunch as Administrator', 'Proceed?', $Choices, 0)
   if ($Decision -eq 0) {
-    $Bootstrap = $MyInvocation.MyCommand.Path
     Start-Process powershell.exe "-ExecutionPolicy ByPass -NoProfile -File $Bootstrap" -Verb RunAs
   }
+
+  $Decision = $Host.UI.PromptForChoice("Remove $Bootstrap", "Proceed?", $Choices, 1)
+  if ($Decision -eq 0) {
+    Remove-Item $Bootstrap -Force
+  }
 } else {
   Write-Host "Running as Administrator. Performing privileged actions."