@echo off setlocal enabledelayedexpansion rem --------------------------------------------------------------------------- rem Adds an "Unpack with fsdecrypt" entry (with icon) to the right-click menu rem of .app and .opt files. Per-user only (HKCU) -- no administrator needed, rem and it does not change the normal double-click association. rem rem Place this next to fsdecrypt.exe and run it, or run it from the repo root rem after `cargo build --release`. Run uninstall-context-menu.bat to undo. rem --------------------------------------------------------------------------- rem --- locate fsdecrypt.exe -------------------------------------------------- set "EXE=" if exist "%~dp0fsdecrypt.exe" set "EXE=%~dp0fsdecrypt.exe" if not defined EXE if exist "%~dp0target\release\fsdecrypt.exe" set "EXE=%~dp0target\release\fsdecrypt.exe" if not defined EXE if exist "%~dp0target\debug\fsdecrypt.exe" set "EXE=%~dp0target\debug\fsdecrypt.exe" if not defined EXE ( echo ERROR: could not find fsdecrypt.exe next to this script or under target\. echo Build it first: cargo build --release pause exit /b 1 ) rem --- locate the icon (optional) -------------------------------------------- set "ICON=" if exist "%~dp0fsdecrypt.ico" set "ICON=%~dp0fsdecrypt.ico" if not defined ICON if exist "%~dp0assets\fsdecrypt.ico" set "ICON=%~dp0assets\fsdecrypt.ico" echo Using exe : !EXE! if defined ICON (echo Using icon: !ICON!) else (echo Using icon: ^(none found^)) echo. call :install ".app" call :install ".opt" echo. echo Done. Right-click a .app or .opt file to see "Unpack with fsdecrypt". echo ^(On Windows 11 it is under "Show more options".^) pause exit /b 0 :install set "KEY=HKCU\Software\Classes\SystemFileAssociations\%~1\shell\fsdecrypt" reg add "%KEY%" /ve /d "Unpack with fsdecrypt" /f >nul if defined ICON reg add "%KEY%" /v Icon /d "!ICON!" /f >nul reg add "%KEY%\command" /ve /d "cmd /c \"\"!EXE!\" \"%%1\" ^& pause\"" /f >nul echo installed for %~1 goto :eof