# ========================================================= # MAX Windows Toolkit - 使用 Geek Uninstaller 卸载软件 # 中文界面,统一风格 # ========================================================= $Common = "C:\Setup\windows\lib\common.ps1" if (Test-Path $Common) { . $Common } Write-Header "使用 Geek Uninstaller 卸载软件" Show-AdminWarn $GeekUrl = "$Global:RepoBase/tools-bin/geek.exe" $LocalToolDir = "C:\Setup\tools" $GeekExe = Join-Path $LocalToolDir "geek.exe" try { New-Item -ItemType Directory -Path $LocalToolDir -Force -ErrorAction Stop | Out-Null } catch {} # 显示已安装的程序 function Show-InstalledPrograms { Write-Section "已安装的桌面程序" $RegistryPaths = @( "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" ) $Programs = foreach ($Path in $RegistryPaths) { Get-ItemProperty $Path -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -and $_.UninstallString } | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate, UninstallString } $Programs | Sort-Object DisplayName | Format-Table DisplayName, DisplayVersion, Publisher -AutoSize } # 显示 Microsoft Store 应用 function Show-StoreApps { Write-Section "已安装的 Microsoft Store 应用" Get-AppxPackage | Sort-Object Name | Select-Object Name, Version, Publisher | Format-Table -AutoSize } # 启动 Geek Uninstaller function Start-GeekUninstaller { param([switch]$StoreApps) if (-not (Test-Path $GeekExe)) { Write-Warn "本地未找到 Geek Uninstaller,正在下载..." if (-not (Download-File -Url $GeekUrl -OutFile $GeekExe)) { Write-Err "下载 Geek Uninstaller 失败" Write-Muted "请检查链接: $GeekUrl" exit 1 } } Write-Info "正在启动 Geek Uninstaller..." try { if ($StoreApps) { Start-Process -FilePath $GeekExe -ArgumentList "/store_apps" } else { Start-Process -FilePath $GeekExe } Write-OK "Geek Uninstaller 已启动" } catch { Write-Err "启动 Geek Uninstaller 失败" Write-Muted $_.Exception.Message } } # 打开程序和功能 function Open-ProgramsAndFeatures { Write-Info "正在打开程序和功能..." Start-Process "appwiz.cpl" } # 打开已安装的应用设置 function Open-InstalledAppsSettings { Write-Info "正在打开已安装的应用设置..." Start-Process "ms-settings:appsfeatures" } # 主菜单循环 :geekLoop while ($true) { Clear-Host Write-Header "使用 Geek Uninstaller 卸载软件" Write-Info "1. 启动 Geek Uninstaller" Write-Info "2. 启动 Geek Uninstaller(Store Apps 视图)" Write-Info "3. 显示已安装的桌面程序" Write-Info "4. 显示已安装的 Microsoft Store 应用" Write-Info "5. 打开 Windows 程序和功能" Write-Info "6. 打开 Windows 已安装应用设置" Write-Info "7. 下载/更新 Geek Uninstaller" Write-Info "0. 退出" Write-Info "" $Choice = Read-Host "请选择" Write-Line switch ($Choice) { "1" { Start-GeekUninstaller; Pause-Max } "2" { Start-GeekUninstaller -StoreApps; Pause-Max } "3" { Show-InstalledPrograms; Pause-Max } "4" { Show-StoreApps; Pause-Max } "5" { Open-ProgramsAndFeatures; Pause-Max } "6" { Open-InstalledAppsSettings; Pause-Max } "7" { if (Test-Path $GeekExe) { Remove-Item $GeekExe -Force -ErrorAction SilentlyContinue } Download-File -Url $GeekUrl -OutFile $GeekExe | Out-Null Pause-Max } "0" { break :geekLoop } default { Write-Err "无效选项"; Pause-Max } } }