Created
April 3, 2026 01:07
-
-
Save baaamn/aa80b64ff67370ac53dd17be9d14b360 to your computer and use it in GitHub Desktop.
promptext-uninstall-robust.ps1: A safer “download then run” wrapper that fetches the upstream scripts/install.ps1 and runs it with -Uninstall, avoiding irm ... | iex.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Filename: Promptext-Uninstall.ps1 | |
| <# | |
| .SYNOPSIS | |
| Robust uninstaller for the promptext CLI on Windows (PowerShell) using a download-then-run workflow. | |
| .DESCRIPTION | |
| This script uninstalls the promptext CLI by downloading the official installer script from the | |
| promptext GitHub repository (via raw.githubusercontent.com) into a temporary file, then executing it | |
| with the -Uninstall switch. | |
| Why this exists: | |
| - Avoids piping remote content directly into iex ("irm ... | iex -Uninstall"). | |
| - Makes the action auditable and easier to troubleshoot. | |
| - Keeps behavior consistent with whatever the upstream project defines as “uninstall”. | |
| The upstream installer/uninstaller typically: | |
| - Removes the install directory (default: %LOCALAPPDATA%\promptext) | |
| - Removes PATH entry (User scope) | |
| - Removes the 'prx' alias line from the PowerShell profile (CurrentUserCurrentHost) | |
| .PARAMETER Branch | |
| Git branch name to fetch the installer from (default: "main"). | |
| Change this to "master" if the repo uses that as the default branch. | |
| .EXAMPLE | |
| # Uninstall using the default branch ("main") upstream script | |
| powershell -ExecutionPolicy Bypass -File .\promptext-uninstall-robust.ps1 | |
| .EXAMPLE | |
| # Uninstall using a different branch (e.g., master) | |
| powershell -ExecutionPolicy Bypass -File .\promptext-uninstall-robust.ps1 -Branch master | |
| .NOTES | |
| v1.0 | |
| - Robust "download then execute" wrapper around the upstream uninstaller behavior: | |
| https://raw.githubusercontent.com/1broseidon/promptext/<branch>/scripts/install.ps1 -Uninstall | |
| Security note: | |
| - Always review scripts before running them in sensitive environments. | |
| #> | |
| #Requires -Version 5.1 | |
| [CmdletBinding()] | |
| param( | |
| [Parameter()] | |
| [string]$Branch = "main" | |
| ) | |
| $ErrorActionPreference = "Stop" | |
| $ProgressPreference = "SilentlyContinue" | |
| # --- Configuration (kept explicit for clarity) --- | |
| $Owner = "1broseidon" | |
| $Repo = "promptext" | |
| $PathInRepo = "scripts/install.ps1" | |
| # Build raw GitHub URL dynamically (no promptext.sh dependency) | |
| $InstallerUrl = "https://raw.githubusercontent.com/$Owner/$Repo/$Branch/$PathInRepo" | |
| # Create a temp file path for the downloaded installer | |
| $TempInstaller = Join-Path $env:TEMP "promptext-install.ps1" | |
| Write-Host "→ Downloading upstream installer (for uninstall)..." -ForegroundColor Blue | |
| Write-Host " URL: $InstallerUrl" -ForegroundColor DarkGray | |
| Write-Host " File: $TempInstaller" -ForegroundColor DarkGray | |
| # Download upstream installer to disk | |
| Invoke-WebRequest -Uri $InstallerUrl -OutFile $TempInstaller -UseBasicParsing | |
| Write-Host "→ Executing upstream uninstaller..." -ForegroundColor Blue | |
| # Execute the downloaded installer with the upstream -Uninstall switch. | |
| & powershell -NoProfile -ExecutionPolicy Bypass -File $TempInstaller -Uninstall | |
| Write-Host "→ Done." -ForegroundColor Green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment