Skip to content

feat: elevate only the link step instead of restarting as admin - #41

Merged
amd989 merged 4 commits into
masterfrom
claude/inspiring-carson-1c38ce
Nov 6, 2026
Merged

amd989 merged 4 commits into
masterfrom
claude/inspiring-carson-1c38ce

Conversation

@amd989

@amd989 amd989 commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

When a symbolic link needs administrator rights (not elevated and Developer Mode off), Symlinker no longer restarts the whole app as administrator. The window stays unelevated and only link creation runs elevated, with a single UAC prompt per session and no restart. The form keeps its values and drag and drop keeps working.

How it works

  • Symlinker.exe --link-helper <pipe> <pid> is a hidden mode (no window) handled in Program.cs.
  • On Create link, ElevateIfNeededAsync() starts that helper with runas and waits for it to connect back over a named pipe. The window then sends link requests (LinkRequest as JSON) and the helper runs mklink and replies with the result, which is shown in the same dialog as before.
  • The helper is started before anything on disk changes: before deleting an existing item at the link path, and right after the user confirms the move-and-link offer from feat: move existing files to the target when creating a link #39. Declining the UAC prompt (Win32 error 1223) quietly stops and leaves everything as it was. Files are never moved and then left without a link because of elevation.
  • The helper stays up until the window closes, so the UAC prompt appears once per session, not once per link. If the helper was ended (e.g. from Task Manager), the next symbolic link starts a new one. While it runs, the UAC shield and the footer notice are hidden. Only symbolic links that need admin go through it; junctions and hard links always run unelevated.
  • Hardening: both pipe ends check the other's process ID (GetNamedPipeClientProcessId / GetNamedPipeServerProcessId), the pipe allows a single instance, and LinkCommand rejects unknown link types and paths with quotes or line breaks. The helper can only ever run one mklink per request.
  • Link paths are sent as full paths, since the elevated helper runs in a different working folder. Targets are sent as entered, so relative symlinks stay relative.

Other changes

  • LinkCommand.cs: mklink runner shared by the window and the helper (moved out of RunMklinkAsync).
  • Removed the "Restart as administrator" dialog, the footer restart link, Elevation.RestartElevated(), LaunchOptions.ToArguments() and the strings ButtonRestartAsAdmin, ButtonNotNow, DialogElevation, DialogElevationTitle.
  • Footer notice now reads "Symbolic links need administrator rights or Developer Mode. Windows will ask for permission when you create the link." It has a tooltip in case a translation is trimmed. The UAC shield on Create link is unchanged.
  • New string ElevationHelperFailed for when the helper can't be reached.
  • All string changes are in Resources.resx, all 8 translations and Resources.Designer.cs.
  • CLAUDE.md: updated components, link flow and the Administrator rights section.
  • Command-line prefill options (--mode, --type, --location, --name, --target) still work.

Testing

  • dotnet build Symlinker/Symlinker.csproj -c Release: 0 errors. The only warning is the existing CS1591 in App.xaml.cs.
  • Helper protocol, driven by a script acting as the window: folder symlink, file symlink and junction created over one connection; a path with " & echo pwned rejected; an existing link reports mklink's error; the helper exits 0 when the pipe closes and exits 3 without reading anything when the parent PID doesn't match.
  • Window, driven with UI Automation on a test build that starts the helper without runas: folder symlink, file symlink and move-and-link all went through the helper (one helper process during the step, none after), and a junction did not use the helper.
  • Same UI Automation test after the session change: one helper process (same PID) served every symbolic link, the junction did not use it, and it exited when the window closed. With Developer Mode off and an unelevated test helper, the move-and-link flow rolled back cleanly when the link failed.
  • Manual check with Developer Mode off (first commit): one UAC prompt, no restart.
  • Manual check with Developer Mode off after the session change: only the first symbolic link asks, later ones don't, and canceling the first prompt leaves everything as it was.

Follow-up

  • Moving a folder to another drive copies nested symbolic links with CreateSymbolicLink in the unelevated window, so that copy fails without Developer Mode (and rolls back). This existed before this PR.

🤖 Generated with Claude Code

amd989 and others added 4 commits November 6, 2026 07:52
When a symbolic link needs administrator rights (no admin, no Developer
Mode), Symlinker used to offer to restart the whole app elevated. That
meant a restart, a UAC prompt, and a new window without drag and drop.

Now the window stays unelevated. Create link starts a hidden copy of
Symlinker.exe (--link-helper) with runas, which shows one UAC prompt and
creates the link over a named pipe. It is started before anything on
disk changes (deleting an existing item or the move-and-link flow), so
declining the prompt quietly stops and leaves everything as it was.

- LinkCommand runs mklink for both the window and the helper, and rejects
  paths with quotes or line breaks.
- Both pipe ends verify the other's process ID.
- Remove the restart dialog, the footer restart link and their strings.
- Footer notice now says Windows will ask for permission.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every Create link started and closed its own elevated helper, so each
symbolic link showed a new UAC prompt. The helper now stays up until the
window closes, so the user approves once per session. If it was ended,
the next symbolic link starts a new one.

- Hide the UAC shield and the footer notice while the helper runs.
- Only symbolic links that need admin go through the helper; junctions
  and hard links stay unelevated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@amd989
amd989 merged commit 1f46a8b into master Nov 6, 2026
1 check passed
amd989 added a commit that referenced this pull request Nov 7, 2026
Now that only the link step elevates (#41), the Store build no longer
needs requireAdministrator. The window starts unelevated, so drag and
drop works, and the hidden link helper shows the UAC prompt through the
allowElevation capability.

- Remove Properties/app.msix.manifest and the MsixBuild switch
- build-msix.ps1 now fails if the exe asks for admin at launch
- Update CLAUDE.md and the privacy policy

Tested with a signed copy of the package and Developer Mode off: the
window ran unelevated, Create link showed one UAC prompt, and the
symbolic link landed in the real %LOCALAPPDATA% folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@amd989
amd989 deleted the claude/inspiring-carson-1c38ce branch November 7, 2026 12:09
amd989 added a commit that referenced this pull request Nov 7, 2026
* feat: 📦 add Microsoft Store (MSIX) package

build-msix.ps1 builds a self-contained x64 + arm64 .msixbundle for
Partner Center, which signs it. The release workflow uploads it as an
artifact.

The Store build uses its own app manifest that asks for admin at start,
since a packaged app cannot relaunch itself with runas. The package
turns off AppData write virtualization so links land where users point.
Program.cs skips the relaunch when already elevated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: 📝 expand the privacy policy

Cover admin rights, update checks per edition, and link the web version
for the Microsoft Store listing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat: ✨ check and test the Store package in build-msix.ps1

Mirror the Readout Store script: verify each package's version,
architecture, capabilities and the exe's requireAdministrator manifest,
print where to upload the bundle, and add -Install (register the unpacked
package) and -Wack (test-sign, install and run the certification kit).
An earlier test copy is removed first so rebuilds don't break it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: 🐛 detect host architecture in Windows PowerShell 5.1

RuntimeInformation.OSArchitecture is missing in 5.1; read the native
architecture from the registry instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: 🐛 use the reserved Store name as the package display name

Partner Center rejects packages whose Properties/DisplayName is not a
reserved name, and "Symlinker" alone is taken. The Start menu name stays
"Symlinker".

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat: ✨ keep the Store listing and screenshot tool in the repo

- listings.json holds the listing text for all 9 package languages
- ScreenshotTool renders the real main window in each language at 2.5x
  under a headline on a 1920x1080 image
- make-listings.ps1 builds the screenshots and fills the exported Partner
  Center template (with and without screenshots)
- README covers the import steps, Partner Center rules, the restricted
  capability text and the certification notes

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat: ✨ start the Store build unelevated

Now that only the link step elevates (#41), the Store build no longer
needs requireAdministrator. The window starts unelevated, so drag and
drop works, and the hidden link helper shows the UAC prompt through the
allowElevation capability.

- Remove Properties/app.msix.manifest and the MsixBuild switch
- build-msix.ps1 now fails if the exe asks for admin at launch
- Update CLAUDE.md and the privacy policy

Tested with a signed copy of the package and Developer Mode off: the
window ran unelevated, Create link showed one UAC prompt, and the
symbolic link landed in the real %LOCALAPPDATA% folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant