Skip to content

Add --no-desktop-shortcut flag for install and upgrade commands #6229

@Skydope

Description

@Skydope

Relevant area(s)

WinGet CLI

Description of the new feature / enhancement

When running winget upgrade [--all], installers may create desktop
shortcuts even when the user did not have them previously. Winget cannot
control the internal logic of each installer type (EXE, MSI, MSIX, Burn,
Inno, NSIS, etc.), so there is no universal flag to prevent shortcut
creation at the source.

Related: #1045, #1545

The proposal is to add an opt-in flag --no-desktop-shortcut that
performs a best-effort cleanup of .lnk files added to the desktop during
the install/upgrade operation. Shortcuts present before the operation
are preserved.

Scope:

  • Desktop shortcuts (.lnk) only, user and shared desktops
  • Commands: install and upgrade
  • Works with --all via flag propagation to sub-contexts
  • Opt-in, no default behavior change

Out of scope (for now):

  • Start Menu, Taskbar, Quick Launch
  • Shortcuts in desktop subdirectories
  • Settings.json persistence (can be a separate PR)

I have a draft implementation ready following the same pipeline pattern as
SnapshotARPEntries / ReportARPChanges. Happy to open a Draft PR if this
direction looks reasonable.

Proposed technical implementation details

The implementation uses a post-install cleanup approach. Pipeline steps
SnapshotDesktopLinks and RemoveNewDesktopLinks are inserted before/after
ExecuteInstaller in InstallPackageInstaller, following the same pattern as
the existing SnapshotARPEntries / ReportARPChanges mechanism.

Desktop paths are resolved via SHGetKnownFolderPath(FOLDERID_Desktop,
FOLDERID_PublicDesktop) for correct OneDrive redirection. weakly_canonical
is used over canonical for path normalization — the latter can throw when
.lnk targets do not exist (network shares, deleted paths), which is a real
edge case on Windows. Guards for extension checks and path containment
prevent race condition / path traversal concerns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions