Skip to content

feat: ✨ add optional Explorer right-click menu entries - #45

Open
amd989 wants to merge 3 commits into
masterfrom
claude/explorer-context-menu-80674e
Open

amd989 wants to merge 3 commits into
masterfrom
claude/explorer-context-menu-80674e

Conversation

@amd989

@amd989 amd989 commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds optional Explorer right-click entries that open Symlinker with the form filled in. Closes #7.

Where you right-click Entry Starts Symlinker with
A file Create link to this --mode file --target "%1"
A folder Create link to this --mode folder --target "%1"
A folder Create link here --location "%1"
A folder's background Create link here --location "%V"

The link name already fills in from the target (#38), so "Create link to this" leaves only the link location to pick. The field order stays as it is (link location first, then target).

How it works

  • Toggle: a new settings button (cog) next to About opens a menu with one checkable item, "Show in Explorer right-click menu". Off by default, no installer step.
  • Registration: ExplorerMenu writes classic shell verbs per user under HKCU\Software\Classes (*\shell, Directory\shell, Directory\Background\shell), so no admin is needed. Each entry uses the exe's icon and MultiSelectModel=Single (one window per right-click; bulk links are Create Bulk Links #6).
  • ClickOnce updates: on every start, if the entries are on but point at another exe (ClickOnce installs each update in a new folder) or use other menu text (Windows language changed), they are rewritten for the running copy.
  • Drive roots: Explorer passes %V for C:\ as "C:\", which Windows splits into C:" and which would swallow any arguments after it. The path is always the last argument, and LaunchOptions.Parse turns a trailing quote on --location / --target back into a backslash. Paths with spaces were already fine.
  • Store (MSIX) build: the settings button is hidden when the app runs packaged (Elevation.IsPackaged()). Registry writes from a packaged app are virtualized, so Explorer would never see them. The manifest is untouched.
  • MainWindow stays glue; the logic is in ExplorerMenu, tested against a throwaway HKCU\Software\SymlinkerTests\<guid> key.

Known limitations

  • Windows 11: classic verbs show under "Show more options", not in the compact menu. Getting into the compact menu needs the same packaged handler described below.
  • Uninstall: removing the ClickOnce or portable version leaves the entries behind, pointing at a missing exe. Turn them off first. (Documented in CLAUDE.md.)

Possible follow-up: Store version

The Store build would need its own context menu handler instead of registry verbs:

  • A small COM server implementing IExplorerCommand (title, icon, Invoke that starts Symlinker with the same arguments), ideally with IExplorerCommandState to hide "Create link here" on files.
  • Declared in the package manifest with desktop4:FileExplorerContextMenus (ItemType *, Directory and Directory\Background) plus a com:Extension SurrogateServer or ExeServer registering the CLSID.
  • This also puts the entries in the Windows 11 compact menu. It would add a native (or AOT) DLL and a manifest change, so it needs another Store certification pass. Not built here.

Strings

New: TooltipSettings, MenuExplorerIntegration, ExplorerMenuLinkTo, ExplorerMenuLinkHere, ExplorerMenuFailed, in Resources.resx and all 8 translations, with typed properties added to Resources.Designer.cs. The menu item sizes to its text, so German, Italian and French fit.

Testing

  • dotnet test --project Symlinker.Tests: 195 passed, line, branch and method coverage at 100%.
  • New tests: enabling writes every key and value, disabling removes only Symlinker's verbs, refresh after an exe move or language change, a missing entry or command key, registry errors (read-only key) in both TrySetEnabled and Refresh, and the registered command lines parsed back through CommandLineToArgvW into LaunchOptions (spaces, drive root).
  • Manual, with the Debug build:
    • Turned the toggle on from the settings menu. All four keys in HKCU\Software\Classes held the expected label, icon and command, and Shell.Application listed "Create link to this" on a file and both entries on a folder.
    • Invoked each verb through the shell: a file opened in File mode with target and name filled in; a folder opened in Folder mode with target and name; "Create link here" filled the link location. The background command with C:\ filled the location as C:\.
    • Set the stored command to an old exe path and started the app: it was rewritten to the running exe.
    • Turned the toggle off: all four keys were gone and the shell no longer listed the entries.
  • Not done by me: a physical right-click in Explorer (my tooling can't right-click there). Worth a quick check before merging.

🤖 Generated with Claude Code

amd989 and others added 2 commits November 17, 2026 07:41
"Create link to this" on files and folders and "Create link here" on
folders and folder backgrounds, registered per user under
HKCU\Software\Classes. Each opens Symlinker with the form prefilled
through the existing command-line options.

- Toggle in a new settings menu next to About, off by default
- Entries are rewritten on startup when they point at another exe
  (ClickOnce moves it on every update) or use other menu text
- Hidden in the Store build, where registry writes are virtualized
- LaunchOptions restores the backslash of a quoted drive root ("C:\")

Closes #7

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…text-menu-80674e

# Conflicts:
#	Symlinker/Properties/Resources.Designer.cs

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement Request: Launch application from context menu and prefill data

1 participant