From 7d6d5d76bb5240302397ceb3796fbdf17034eacd Mon Sep 17 00:00:00 2001 From: sudo-py-dev Date: Thu, 29 Oct 2026 10:52:36 +0200 Subject: [PATCH 1/3] Store app and Edge removal fixes; a cleaner Hunter target - Store apps: no restore point (System Restore can't bring one back), so uninstalling one no longer stops when System Restore is off - The leftover scan never offers WindowsApps package folders: only Windows can delete them, and trying ended in Access denied - Store app list: SignatureKind read as text, so system apps are recognized - Edge/OneDrive scripts create registry keys only when missing: New-Item -Force emptied existing ones (EdgeUpdate, its policies, the default profile's Run key, OneDrive's Explorer entry) - Uninstallers are waited for themselves, not with Start-Process -Wait, which also waited for every helper they left running - Edge removal also deletes Edge's downloaded update installer - Hunter: larger round target, a title bar that drags from anywhere, smaller buttons, label no longer cut off Co-Authored-By: Claude Opus 5.5 --- src/gui/hunter.rs | 66 ++++++++++++++++++++++------------ src/gui/uninstaller.rs | 3 +- src/keepaway.rs | 66 ++++++++++++++++++++++++++-------- src/main.rs | 6 ++-- src/platform/windows_uninst.rs | 32 +++++++++++++++-- src/uninstaller/mod.rs | 36 +++++++++++++++++++ 6 files changed, 165 insertions(+), 44 deletions(-) diff --git a/src/gui/hunter.rs b/src/gui/hunter.rs index 2cd2fc2..46275a9 100644 --- a/src/gui/hunter.rs +++ b/src/gui/hunter.rs @@ -104,7 +104,7 @@ impl HunterView { let (mut hunted, mut close, mut open_main, mut hide) = (false, false, false, false); let builder = egui::ViewportBuilder::default() .with_title("CleanCore Hunter") - .with_inner_size([128.0, 132.0]) + .with_inner_size([132.0, 150.0]) .with_resizable(false) .with_decorations(false) .with_always_on_top() @@ -113,37 +113,41 @@ impl HunterView { if ui.input(|i| i.viewport().close_requested()) { close = true; } - egui::CentralPanel::default().frame(egui::Frame::new().fill(p.surface).stroke(egui::Stroke::new(1.0, p.border)).inner_margin(6)).show(ui, |ui| { - crate::gui::style::row(ui, |ui| { - // Grip: drag the window around. Its buttons sit at the far end. - ui.spacing_mut().item_spacing.x = 0.0; - let (grip, r) = ui.allocate_exact_size(egui::vec2(24.0, 30.0), egui::Sense::drag()); - ui.painter().text(grip.center(), egui::Align2::CENTER_CENTER, style::vstr(icon::DOTS), egui::FontId::proportional(14.0), p.faint); - if r.hovered() { - ui.ctx().set_cursor_icon(egui::CursorIcon::Grab); - } - if r.drag_started() { - ui.ctx().send_viewport_cmd(egui::ViewportCommand::StartDrag); - } - r.on_hover_text(style::vis(tr("Move"))); - ui.with_layout(crate::gui::style::far_layout(egui::Align::Center), |ui| { - close = style::icon_button(ui, icon::X, "Exit Hunter Mode").clicked() || close; - hide = style::icon_button(ui, icon::APP_WINDOW, "Open CleanCore").clicked(); - }); - }); + egui::CentralPanel::default().frame(egui::Frame::new().fill(p.surface).stroke(egui::Stroke::new(1.0, p.border)).inner_margin(egui::Margin::symmetric(6, 4))).show(ui, |ui| { + // Title bar: all of it moves the window, except its two small buttons at the far end. + let (bar, r) = ui.allocate_exact_size(egui::vec2(ui.available_width(), 26.0), egui::Sense::drag()); + if r.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::Grab); + } + if r.drag_started() { + ui.ctx().send_viewport_cmd(egui::ViewportCommand::StartDrag); + } + r.on_hover_text(style::vis(tr("Move"))); + let mut buttons = ui.new_child(egui::UiBuilder::new().max_rect(bar).layout(style::far_layout(egui::Align::Center))); + buttons.spacing_mut().item_spacing.x = 2.0; + close = bar_button(&mut buttons, icon::X, "Exit Hunter Mode", p).clicked() || close; + hide = bar_button(&mut buttons, icon::APP_WINDOW, "Open CleanCore", p).clicked(); + + ui.add_space(4.0); ui.vertical_centered(|ui| { - let (rect, r) = ui.allocate_exact_size(egui::vec2(64.0, 64.0), egui::Sense::drag()); + // The target: a round button with a ring that answers hover, red while hunting. + let (rect, r) = ui.allocate_exact_size(egui::vec2(72.0, 72.0), egui::Sense::drag()); r.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, tr("Floating hunter target"))); + let hover = ui.ctx().animate_bool(r.id, r.hovered() || r.dragged()); let col = if r.dragged() { p.danger } else { p.accent }; - ui.painter().rect_filled(rect, 16.0, col.gamma_multiply(if p.dark { 0.25 } else { 0.14 })); - ui.painter().text(rect.center(), egui::Align2::CENTER_CENTER, style::vstr(icon::CROSSHAIR), egui::FontId::proportional(38.0), col); + let painter = ui.painter(); + let radius = 30.0 + 2.0 * hover; + painter.circle_filled(rect.center(), radius, col.gamma_multiply(if p.dark { 0.22 } else { 0.12 } + 0.08 * hover)); + painter.circle_stroke(rect.center(), radius, egui::Stroke::new(1.5, col.gamma_multiply(0.35 + 0.65 * hover))); + painter.text(rect.center(), egui::Align2::CENTER_CENTER, style::vstr(icon::CROSSHAIR), egui::FontId::proportional(34.0 + 2.0 * hover), col); if r.hovered() || r.dragged() { ui.ctx().set_cursor_icon(egui::CursorIcon::Crosshair); } if r.drag_stopped() { hunted = true; } - ui.add(style::Label::new(style::rich(tr("Drag me")).size(11.0).color(p.muted))); + ui.add_space(2.0); + ui.add(style::Label::new(style::rich(tr("Drag me")).size(12.0).color(if r.dragged() { p.danger } else { p.muted }))); }); }); }); @@ -526,6 +530,22 @@ fn program_row(ui: &mut Ui, pr: &Proc, selected: bool, p: Palette) -> egui::Resp } /// Bring the main window back from the taskbar. +/// A small icon button for the floating target's title bar (the usual ones would crowd it). +fn bar_button(ui: &mut Ui, glyph: &str, tip: &str, p: Palette) -> egui::Response { + let tip = tr(tip); + let (rect, r) = ui.allocate_exact_size(egui::vec2(24.0, 24.0), egui::Sense::click()); + let t = ui.ctx().animate_bool(r.id, r.hovered()); + if t > 0.0 { + ui.painter().rect_filled(rect, 6.0, p.surface_alt.lerp_to_gamma(p.border, 0.5).gamma_multiply(t)); + } + ui.painter().text(rect.center(), egui::Align2::CENTER_CENTER, style::vstr(glyph), egui::FontId::proportional(14.0), p.faint.lerp_to_gamma(p.text, t)); + if r.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + r.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, tip.clone())); + r.on_hover_text(style::vis(tip)) +} + fn show_main(ctx: &egui::Context) { ctx.send_viewport_cmd_to(egui::ViewportId::ROOT, egui::ViewportCommand::Minimized(false)); ctx.send_viewport_cmd_to(egui::ViewportId::ROOT, egui::ViewportCommand::Focus); diff --git a/src/gui/uninstaller.rs b/src/gui/uninstaller.rs index b3627c2..3836a7b 100644 --- a/src/gui/uninstaller.rs +++ b/src/gui/uninstaller.rs @@ -79,6 +79,7 @@ enum Ran { /// the program's own uninstaller when there is one. `turn_on_restore` first switches System /// Restore back on (the user's choice after it failed). fn first_stage(settings: &Settings, label: &str, prog: Option<&Program>, run_mode: RunMode, restore_point: bool, turn_on_restore: bool) -> Result { + let settings = &uninst::settings_for(settings, prog); if turn_on_restore { if let Err(e) = crate::platform::enable_system_restore() { return Ok(Ran::RestorePointFailed(crate::tf!("Turning on System Restore failed: {e:#}"))); @@ -366,7 +367,7 @@ impl UninstallerView { } fn start_queue(&mut self, ctx: &egui::Context, cx: &Cx, items: Vec) { - let settings = cx.settings.clone(); + let settings = uninst::settings_for(cx.settings, &items); let label = crate::tf!("{} program(s)", items.len()); let prepared = Pending::spawn(ctx, "Creating restore point and backup", move || uninst::prepare(&settings, &label)); self.screen = Screen::Queue(Queue { diff --git a/src/keepaway.rs b/src/keepaway.rs index d0b9b9c..48b29c2 100644 --- a/src/keepaway.rs +++ b/src/keepaway.rs @@ -120,17 +120,30 @@ function Remove-Autostart($like) { } "#; +/// Put before a script that calls `Invoke-Uninstaller $exe $arguments`: it runs the uninstaller +/// and waits for it, and for the copies of it named `$name` it hands over to, 5 minutes at most. +/// `Start-Process -Wait` waits for every process the uninstaller starts too, so an uninstaller +/// that leaves Edge Update or a helper running held the removal until PowerShell was stopped. +const RUN: &str = r#" +function Invoke-Uninstaller($exe, $arguments, $name) { + $until = (Get-Date).AddMinutes(5) + $p = Start-Process $exe $arguments -PassThru + if ($p) { [void]$p.WaitForExit(300000) } + while ($name -and (Get-Date) -lt $until -and @(Get-Process -Name $name -ErrorAction SilentlyContinue).Count) { Start-Sleep -Milliseconds 500 } +} +"#; + /// OneDrive: its own uninstallers (this user's copy, then the machine-wide one). const ONEDRIVE_REMOVE: &str = r#" $ErrorActionPreference = 'SilentlyContinue' Stop-Process -Name OneDrive, OneDriveSetup -Force Start-Sleep -Seconds 1 -Get-ChildItem "$env:LOCALAPPDATA\Microsoft\OneDrive\*\OneDriveSetup.exe" | ForEach-Object { Start-Process $_.FullName '/uninstall' -Wait } +Get-ChildItem "$env:LOCALAPPDATA\Microsoft\OneDrive\*\OneDriveSetup.exe" | ForEach-Object { Invoke-Uninstaller $_.FullName '/uninstall' 'OneDriveSetup' } foreach ($d in $env:ProgramFiles, ${env:ProgramFiles(x86)}) { - Get-ChildItem "$d\Microsoft OneDrive\*\OneDriveSetup.exe" | ForEach-Object { Start-Process $_.FullName '/uninstall /allusers' -Wait } + Get-ChildItem "$d\Microsoft OneDrive\*\OneDriveSetup.exe" | ForEach-Object { Invoke-Uninstaller $_.FullName '/uninstall /allusers' 'OneDriveSetup' } } foreach ($s in "$env:SystemRoot\System32\OneDriveSetup.exe", "$env:SystemRoot\SysWOW64\OneDriveSetup.exe") { - if (Test-Path $s) { Start-Process $s '/uninstall' -Wait } + if (Test-Path $s) { Invoke-Uninstaller $s '/uninstall' 'OneDriveSetup' } } "#; @@ -139,7 +152,7 @@ const ONEDRIVE_BLOCK: &str = r#" $ErrorActionPreference = 'SilentlyContinue' # The policy "Prevent the usage of OneDrive for file storage": OneDrive won't run for anyone. $pol = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive' -New-Item $pol -Force | Out-Null +if (-not (Test-Path $pol)) { New-Item $pol -Force | Out-Null } Set-ItemProperty $pol -Name DisableFileSyncNGSC -Value 1 -Type DWord # New accounts: the default profile installs it at first sign-in. $hive = "$env:SystemDrive\Users\Default\NTUSER.DAT" @@ -156,7 +169,7 @@ Remove-Autostart 'OneDrive*' Get-ScheduledTask -TaskName 'OneDrive*' | Unregister-ScheduledTask -Confirm:$false # Explorer's sidebar entry. foreach ($c in 'HKCU:\Software\Classes\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}', 'HKCU:\Software\Classes\WOW6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}') { - New-Item $c -Force | Out-Null + if (-not (Test-Path $c)) { New-Item $c -Force | Out-Null } Set-ItemProperty $c -Name 'System.IsPinnedToNameSpaceTree' -Value 0 -Type DWord } Write-Output $old @@ -172,8 +185,9 @@ foreach ($c in 'HKCU:\Software\Classes\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1F $hive = "$env:SystemDrive\Users\Default\NTUSER.DAT" if ($old -and (Test-Path $hive)) { reg.exe load 'HKU\CleanCoreDefault' $hive | Out-Null - New-Item 'Registry::HKEY_USERS\CleanCoreDefault\Software\Microsoft\Windows\CurrentVersion\Run' -Force | Out-Null - Set-ItemProperty 'Registry::HKEY_USERS\CleanCoreDefault\Software\Microsoft\Windows\CurrentVersion\Run' -Name OneDriveSetup -Value $old + $run = 'Registry::HKEY_USERS\CleanCoreDefault\Software\Microsoft\Windows\CurrentVersion\Run' + if (-not (Test-Path $run)) { New-Item $run -Force | Out-Null } + Set-ItemProperty $run -Name OneDriveSetup -Value $old [gc]::Collect() reg.exe unload 'HKU\CleanCoreDefault' | Out-Null } @@ -208,16 +222,19 @@ function Stop-Edge { Stop-Edge $dev = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdateDev' -New-Item $dev -Force | Out-Null +if (-not (Test-Path $dev)) { New-Item $dev -Force | Out-Null } Set-ItemProperty $dev -Name AllowUninstall -Value 1 -Type DWord $legacy = "$env:SystemRoot\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe" $made = -not (Test-Path "$legacy\MicrosoftEdge.exe") if ($made) { New-Item $legacy -ItemType Directory -Force | Out-Null; New-Item "$legacy\MicrosoftEdge.exe" -ItemType File -Force | Out-Null } foreach ($r in $roots) { Get-ChildItem "$r\Application\*\Installer\setup.exe" | ForEach-Object { - Start-Process $_.FullName '--uninstall --msedge --system-level --verbose-logging --force-uninstall' -Wait + Invoke-Uninstaller $_.FullName '--uninstall --msedge --system-level --verbose-logging --force-uninstall' } } +# A copy of Edge's setup it handed over to (setup.exe is a common name: only Edge's counts). +$until = (Get-Date).AddMinutes(2) +while ((Get-Date) -lt $until -and @(Get-Process setup | Where-Object { $_.Product -like '*Edge*' -and $_.Product -notlike '*WebView*' }).Count) { Start-Sleep -Milliseconds 500 } if ($made) { Remove-Item "$legacy\MicrosoftEdge.exe" -Force } Remove-ItemProperty $dev -Name AllowUninstall @@ -225,7 +242,6 @@ Remove-ItemProperty $dev -Name AllowUninstall Stop-Edge $svc = Get-CimInstance Win32_Service -Filter "Name='MicrosoftEdgeElevationService'" if ($svc -and @($roots | Where-Object { $svc.PathName.Trim('"').StartsWith("$_\", 'OrdinalIgnoreCase') }).Count) { sc.exe delete MicrosoftEdgeElevationService | Out-Null } -Add-Type -Namespace CleanCore -Name Kernel32 -MemberDefinition '[DllImport("kernel32.dll", CharSet = CharSet.Unicode)] public static extern bool MoveFileEx(string from, string to, int flags);' foreach ($r in $roots) { if (-not (Test-Path -LiteralPath $r)) { continue } # Ownership to Administrators, then full control for them. takeown's prompt (for folders it @@ -237,6 +253,10 @@ foreach ($r in $roots) { Remove-Item -LiteralPath $r -Recurse -Force if (Test-Path -LiteralPath $r) { # Still in use: deleted when Windows restarts, deepest first so each folder is empty by then. + # (Compiling MoveFileEx's wrapper takes a few seconds: only when it is needed.) + if (-not ('CleanCore.Kernel32' -as [type])) { + Add-Type -Namespace CleanCore -Name Kernel32 -MemberDefinition '[DllImport("kernel32.dll", CharSet = CharSet.Unicode)] public static extern bool MoveFileEx(string from, string to, int flags);' + } @(Get-ChildItem -LiteralPath $r -Recurse -Force) + @(Get-Item -LiteralPath $r) | Sort-Object { $_.FullName.Length } -Descending | ForEach-Object { [CleanCore.Kernel32]::MoveFileEx($_.FullName, [NullString]::Value, 4) | Out-Null } 'REBOOT' } @@ -249,6 +269,9 @@ foreach ($k in 'HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components', 'HK Remove-Item "$k\{9459C573-B17A-45AE-9F64-1857B5D58CEE}" -Recurse -Force } +# The Edge installer Edge Update downloaded for its next update (Edge's app id only). +Remove-Item "${env:ProgramFiles(x86)}\Microsoft\EdgeUpdate\Download\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Recurse -Force + # Its Store placeholder and shortcuts. Get-AppxPackage -AllUsers 'Microsoft.MicrosoftEdge.Stable' | Remove-AppxPackage -AllUsers Remove-Item "$env:PUBLIC\Desktop\Microsoft Edge.lnk", "$env:USERPROFILE\Desktop\Microsoft Edge.lnk", "$env:ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk" -Force @@ -259,11 +282,11 @@ const EDGE_BLOCK: &str = r#" $ErrorActionPreference = 'SilentlyContinue' # Microsoft's blocker for the automatic switch to the new Edge. $eu = 'HKLM:\SOFTWARE\Microsoft\EdgeUpdate' -New-Item $eu -Force | Out-Null +if (-not (Test-Path $eu)) { New-Item $eu -Force | Out-Null } Set-ItemProperty $eu -Name DoNotUpdateToEdgeWithChromium -Value 1 -Type DWord # Edge Update policies: don't install Edge, nor put its shortcut on the desktop. $pol = 'HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate' -New-Item $pol -Force | Out-Null +if (-not (Test-Path $pol)) { New-Item $pol -Force | Out-Null } Set-ItemProperty $pol -Name 'Install{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}' -Value 0 -Type DWord Set-ItemProperty $pol -Name 'CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}' -Value 0 -Type DWord # Edge Update off: its services and scheduled tasks are disabled, not deleted (Allow turns them @@ -325,7 +348,7 @@ pub fn uninstall_edge() -> Result { /// Run `EDGE_REMOVE`; true when some files are deleted at the next restart. fn remove_edge() -> Result { - Ok(ps(&format!("{AUTOSTART}{EDGE_REMOVE}"))?.lines().any(|l| l.trim() == "REBOOT")) + Ok(ps(&format!("{AUTOSTART}{RUN}{EDGE_REMOVE}"))?.lines().any(|l| l.trim() == "REBOOT")) } /// Remove the app and block it from coming back. Keeps the daily check running. @@ -345,7 +368,7 @@ pub fn remove(app: App) -> Result { None } App::OneDrive => { - ps(ONEDRIVE_REMOVE)?; + ps(&format!("{RUN}{ONEDRIVE_REMOVE}"))?; let old = ps(&format!("{AUTOSTART}{ONEDRIVE_BLOCK}"))?.trim().to_string(); // Keep an entry saved by an earlier removal: this run found it already gone. Some(old).filter(|s| !s.is_empty()).or_else(|| k.get(app).and_then(|r| r.default_run.clone())) @@ -458,11 +481,24 @@ mod tests { assert!(!EDGE_REMOVE.contains("sc.exe delete edgeupdate")); } + /// `New-Item -Force` on a registry key that exists empties it (values and subkeys), so a + /// key is only ever created when it is missing; and no uninstaller is waited for with + /// `Start-Process -Wait`, which also waits for whatever it leaves running. + #[test] + fn keeps_existing_keys_and_waits_for_the_uninstaller_only() { + for s in [AUTOSTART, RUN, EDGE_REMOVE, EDGE_BLOCK, EDGE_ALLOW, ONEDRIVE_REMOVE, ONEDRIVE_BLOCK, ONEDRIVE_ALLOW] { + for line in s.lines().filter(|l| l.contains("New-Item") && !l.contains("-ItemType")) { + assert!(line.contains("if (-not (Test-Path "), "{line}"); + } + assert!(!s.contains("-Wait"), "{s}"); + } + } + /// The scripts parse (PowerShell's own parser: nothing runs). #[test] #[cfg(windows)] fn scripts_parse() { - for s in [AUTOSTART, EDGE_REMOVE, EDGE_BLOCK, EDGE_ALLOW, ONEDRIVE_REMOVE, ONEDRIVE_BLOCK, ONEDRIVE_ALLOW] { + for s in [AUTOSTART, RUN, EDGE_REMOVE, EDGE_BLOCK, EDGE_ALLOW, ONEDRIVE_REMOVE, ONEDRIVE_BLOCK, ONEDRIVE_ALLOW] { let check = "$e = $null; [void][System.Management.Automation.Language.Parser]::ParseInput($env:CLEANCORE_SCRIPT, [ref]$null, [ref]$e); if ($e) { $e | ForEach-Object { $_.Message }; exit 1 }"; let o = std::process::Command::new("powershell").args(["-NoProfile", "-NonInteractive", "-Command", check]).env("CLEANCORE_SCRIPT", s).output().unwrap(); assert!(o.status.success(), "{}\n{s}", String::from_utf8_lossy(&o.stdout)); diff --git a/src/main.rs b/src/main.rs index 594c672..310a30e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2428,7 +2428,7 @@ fn run_uninstall(settings: &Settings, a: UninstallArgs) -> Result<()> { if !a.yes && !confirm(&format!("Quick uninstall {} program(s): {}?", programs.len(), programs.iter().map(|p| p.name.as_str()).collect::>().join(", ")))? { return Ok(()); } - prepare_uninstall(settings, &format!("{} program(s)", programs.len()), a.yes)?; + prepare_uninstall(&uninst::settings_for(settings, &programs), &format!("{} program(s)", programs.len()), a.yes)?; let mut s2 = settings.clone(); if let Some(m) = a.mode { s2.uninstall_scan_mode = m; @@ -2451,8 +2451,8 @@ fn run_uninstall(settings: &Settings, a: UninstallArgs) -> Result<()> { t.paths.extend(a.path.iter().cloned()); return leftovers_step(settings, &t, &a, &p.name, &p.version, Operation::LeftoversOnly); } - prepare_uninstall(settings, &p.name, a.yes)?; - let mode = if a.msi { RunMode::ForcedMsi } else { RunMode::Normal }; + prepare_uninstall(&uninst::settings_for(settings, [p]), &p.name, a.yes)?; + let mode =if a.msi { RunMode::ForcedMsi } else { RunMode::Normal }; if p.uninstall_string.is_none() && !a.msi { println!("No built-in uninstaller: removing the program's files and leftovers."); return leftovers_step(settings, &target, &a, &p.name, &p.version, Operation::Uninstall); diff --git a/src/platform/windows_uninst.rs b/src/platform/windows_uninst.rs index 9c755c4..f1cb05e 100644 --- a/src/platform/windows_uninst.rs +++ b/src/platform/windows_uninst.rs @@ -177,8 +177,17 @@ pub fn in_windows_dir(path: &str) -> bool { p == root || p.starts_with(&format!("{root}\\")) } +/// Store app package folders (`Program Files\WindowsApps`, `:\WindowsApps`) and app +/// aliases (`AppData\Local\Microsoft\WindowsApps`) are Windows' deployment service's: only it +/// can delete them (anyone else gets Access denied), and it does once no account still has the +/// package, which a removal for this user alone often leaves (new accounts get it too). +fn in_windows_apps(path: &str) -> bool { + path.split(['\\', '/']).any(|c| c.eq_ignore_ascii_case("WindowsApps")) +} + fn store_apps(show_system: bool) -> Vec { - let script = "Get-AppxPackage | Select-Object Name,PackageFullName,PackageFamilyName,Version,Publisher,InstallLocation,IsFramework,SignatureKind,NonRemovable | ConvertTo-Json -Compress"; + // SignatureKind as its name: ConvertTo-Json writes enums as numbers. + let script = "Get-AppxPackage | Select-Object Name,PackageFullName,PackageFamilyName,Version,Publisher,InstallLocation,IsFramework,@{n='SignatureKind';e={\"$($_.SignatureKind)\"}},NonRemovable | ConvertTo-Json -Compress"; let Ok(text) = powershell(script) else { return Vec::new(); }; @@ -347,7 +356,7 @@ impl Scan<'_> { fn file(&mut self, p: &Path, what: &str) { let s = p.display().to_string(); - if self.other_owns(&s) { + if self.other_owns(&s) || in_windows_apps(&s) { return; } let Ok(meta) = std::fs::symlink_metadata(p) else { @@ -618,3 +627,22 @@ pub fn scan_leftovers(target: &Target, mode: ScanMode, scope: Scope, others: &[P } s.out } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn store_app_folders_are_never_leftovers() { + for p in [ + r"C:\Program Files\WindowsApps\MicrosoftCorporationII.QuickAssist_2.0.5.0_x64__8wekyb3d8bbwe", + r"D:\WindowsApps\Some.App_1.0.0.0_x64__abc", + r"C:\Users\me\AppData\Local\Microsoft\WindowsApps\Some.App_abc", + ] { + assert!(in_windows_apps(p), "{p}"); + } + for p in [r"C:\Users\me\AppData\Local\Packages\Some.App_abc", r"C:\Program Files\WindowsAppsTool"] { + assert!(!in_windows_apps(p), "{p}"); + } + } +} diff --git a/src/uninstaller/mod.rs b/src/uninstaller/mod.rs index 7f7cc63..cd162ac 100644 --- a/src/uninstaller/mod.rs +++ b/src/uninstaller/mod.rs @@ -580,6 +580,27 @@ pub fn prepare(settings: &Settings, label: &str) -> std::result::Result(programs: impl IntoIterator) -> bool { + let mut any = false; + for p in programs { + if p.kind != ProgramKind::WindowsApp { + return true; + } + any = true; + } + !any +} + +/// `settings` to `prepare` the uninstall of `programs` with: no restore point where it can't help. +pub fn settings_for<'a>(settings: &Settings, programs: impl IntoIterator) -> Settings { + let mut s = settings.clone(); + s.uninstall_restore_point &= restore_point_helps(programs); + s +} + /// `prepare` once the user chose to go on although the restore point failed. pub fn prepare_without_restore_point(settings: &Settings, label: &str) -> Vec { let mut s = settings.clone(); @@ -1000,6 +1021,21 @@ pub fn export(programs: &[Program], path: &std::path::Path) -> Result<()> { mod tests { use super::*; + #[test] + fn store_apps_alone_make_no_restore_point() { + let app = Program::new("a", "Quick Assist", ProgramKind::WindowsApp); + let win32 = Program::new("w", "Notepad++", ProgramKind::Win32); + let mut s = Settings::default(); + s.uninstall_restore_point = true; + assert!(!settings_for(&s, [&app]).uninstall_restore_point); + assert!(!settings_for(&s, &vec![app.clone(), app.clone()]).uninstall_restore_point); + assert!(settings_for(&s, [&app, &win32]).uninstall_restore_point); + // Forced Uninstall (no program) and a switched-off setting stay as they are. + assert!(settings_for(&s, None).uninstall_restore_point); + s.uninstall_restore_point = false; + assert!(!settings_for(&s, [&win32]).uninstall_restore_point); + } + #[test] fn never_offers_the_runtimes_edge_shares() { for kept in [ From 75d1315e1a97775178bb556bd590f0616e6ec32e Mon Sep 17 00:00:00 2001 From: sudo-py-dev Date: Thu, 29 Oct 2026 10:54:22 +0200 Subject: [PATCH 2/3] Format with rustfmt Co-Authored-By: Claude Opus 5.5 --- src/gui/hunter.rs | 3 ++- src/main.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/hunter.rs b/src/gui/hunter.rs index 46275a9..4e97de3 100644 --- a/src/gui/hunter.rs +++ b/src/gui/hunter.rs @@ -113,7 +113,8 @@ impl HunterView { if ui.input(|i| i.viewport().close_requested()) { close = true; } - egui::CentralPanel::default().frame(egui::Frame::new().fill(p.surface).stroke(egui::Stroke::new(1.0, p.border)).inner_margin(egui::Margin::symmetric(6, 4))).show(ui, |ui| { + let frame = egui::Frame::new().fill(p.surface).stroke(egui::Stroke::new(1.0, p.border)).inner_margin(egui::Margin::symmetric(6, 4)); + egui::CentralPanel::default().frame(frame).show(ui, |ui| { // Title bar: all of it moves the window, except its two small buttons at the far end. let (bar, r) = ui.allocate_exact_size(egui::vec2(ui.available_width(), 26.0), egui::Sense::drag()); if r.hovered() { diff --git a/src/main.rs b/src/main.rs index 310a30e..0583c27 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2452,7 +2452,7 @@ fn run_uninstall(settings: &Settings, a: UninstallArgs) -> Result<()> { return leftovers_step(settings, &t, &a, &p.name, &p.version, Operation::LeftoversOnly); } prepare_uninstall(&uninst::settings_for(settings, [p]), &p.name, a.yes)?; - let mode =if a.msi { RunMode::ForcedMsi } else { RunMode::Normal }; + let mode = if a.msi { RunMode::ForcedMsi } else { RunMode::Normal }; if p.uninstall_string.is_none() && !a.msi { println!("No built-in uninstaller: removing the program's files and leftovers."); return leftovers_step(settings, &target, &a, &p.name, &p.version, Operation::Uninstall); From ca8838dbb757c60450311190b05ae42108bb8586 Mon Sep 17 00:00:00 2001 From: sudo-py-dev Date: Thu, 29 Oct 2026 11:04:51 +0200 Subject: [PATCH 3/3] Edge removal waits for any Edge setup; drop a needless clone Co-Authored-By: Claude Opus 5.5 --- src/gui/hunter.rs | 2 +- src/keepaway.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/hunter.rs b/src/gui/hunter.rs index 4e97de3..4c032f0 100644 --- a/src/gui/hunter.rs +++ b/src/gui/hunter.rs @@ -543,7 +543,7 @@ fn bar_button(ui: &mut Ui, glyph: &str, tip: &str, p: Palette) -> egui::Response if r.hovered() { ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); } - r.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, tip.clone())); + r.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, tip)); r.on_hover_text(style::vis(tip)) } diff --git a/src/keepaway.rs b/src/keepaway.rs index 48b29c2..ea78934 100644 --- a/src/keepaway.rs +++ b/src/keepaway.rs @@ -233,8 +233,9 @@ foreach ($r in $roots) { } } # A copy of Edge's setup it handed over to (setup.exe is a common name: only Edge's counts). +# Only waited for, never stopped. $until = (Get-Date).AddMinutes(2) -while ((Get-Date) -lt $until -and @(Get-Process setup | Where-Object { $_.Product -like '*Edge*' -and $_.Product -notlike '*WebView*' }).Count) { Start-Sleep -Milliseconds 500 } +while ((Get-Date) -lt $until -and @(Get-Process setup | Where-Object { $_.Product -like '*Edge*' }).Count) { Start-Sleep -Milliseconds 500 } if ($made) { Remove-Item "$legacy\MicrosoftEdge.exe" -Force } Remove-ItemProperty $dev -Name AllowUninstall