CmdPal: Hide uninstall option for system apps#48804
Merged
michaeljolley merged 3 commits intoJun 24, 2026
Merged
Conversation
System-signed UWP packages (Settings, Task Manager, Registry Editor) should not show an uninstall option in the context menu. Add IsNonRemovable property threaded from Windows.ApplicationModel.Package .SignatureKind through PackageWrapper -> IPackage -> UWP, and gate the Uninstall command on !Package.IsNonRemovable. For Win32/.lnk apps, add IsProtectedSystemApp() which checks whether the resolved executable path lives inside %SystemRoot% (C:\Windows), and IsShortcutTarget() which detects unresolved shortcut chains. Add PathHelpers.IsPathInsideDirectory() utility with directory-boundary- aware comparison to avoid false positives (e.g. C:\WindowsFake). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
|
what's the deal with this and #48797? just based on titles, these are the same thing? squad lick the same cookie twice? |
Contributor
Author
Something went wonky with the git worktree. So, 48797 was showing changes that weren't changes for this work. It was including odd stuff like your teachable tip work. Left it as draft so copilot could review it to build out this one. This is the actual PR. |
zadjii-msft
requested changes
Jun 23, 2026
- Remove reflection-based SystemAppDetectionTests; the project already has InternalsVisibleTo so reflection was unnecessary and fragile. - Extract IsSystemRootPath() and IsShortcutFile() into PathHelpers as testable internal helpers that accept plain string paths. - Narrow bare catch in PathHelpers to ArgumentException | IOException | SecurityException and log via ManagedCommon Logger. - Expand PathHelpersTests to cover IsSystemRootPath and IsShortcutFile with null/empty, boundary, and case-insensitivity cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address review feedback from @zadjii-msft: - Cache %SystemRoot% in a static readonly field so it's resolved once rather than per-app. - Replace Path.GetFullPath (which hits the filesystem) with pure string normalization (TrimEnd + append separator + StartsWith). The paths stored on Win32Program are already absolute, so filesystem resolution is unnecessary overhead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
zadjii-msft
approved these changes
Jun 24, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Command Palette currently shows the "Uninstall" context menu option for system apps like Windows Settings, Registry Editor, and Task Manager. Users can accidentally trigger uninstall on packages that should not be removable. This PR hides the uninstall option for system apps.
It's probably not a perfect solution, but seemed to catch all I tried to test.
Fixes #46826