Skip to content

CmdPal: Hide uninstall option for system apps#48804

Merged
michaeljolley merged 3 commits into
mainfrom
dev/mjolley/fix-cmdpal-hide-uninstall-system-apps
Jun 24, 2026
Merged

CmdPal: Hide uninstall option for system apps#48804
michaeljolley merged 3 commits into
mainfrom
dev/mjolley/fix-cmdpal-hide-uninstall-system-apps

Conversation

@michaeljolley

@michaeljolley michaeljolley commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

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

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>
@github-actions github-actions Bot added the Product-Command Palette Refers to the Command Palette utility label Jun 22, 2026
@michaeljolley michaeljolley self-assigned this Jun 22, 2026
@zadjii-msft

Copy link
Copy Markdown
Member

what's the deal with this and #48797? just based on titles, these are the same thing? squad lick the same cookie twice?

@michaeljolley

Copy link
Copy Markdown
Contributor Author

what's the deal with this and #48797? just based on titles, these are the same thing? squad lick the same cookie twice?

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 zadjii-msft left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple questions

Comment thread src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs Outdated
michaeljolley and others added 2 commits June 23, 2026 23:06
- 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>
@michaeljolley michaeljolley added the Needs-Review This Pull Request awaits the review of a maintainer. label Jun 24, 2026
@michaeljolley

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@michaeljolley michaeljolley added Needs-Review This Pull Request awaits the review of a maintainer. and removed Needs-Review This Pull Request awaits the review of a maintainer. labels Jun 24, 2026
@michaeljolley michaeljolley merged commit ada75d0 into main Jun 24, 2026
8 checks passed
@michaeljolley michaeljolley deleted the dev/mjolley/fix-cmdpal-hide-uninstall-system-apps branch June 24, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs-Review This Pull Request awaits the review of a maintainer. Product-Command Palette Refers to the Command Palette utility

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

CmdPal shows the uninstall button for system apps that arent supposed to be uninstalled

2 participants