Create custom commands in the modern context menu and enable/disable commands from other apps.
Note
- An application can only register a single root command in the modern context menu.
- Subcommands which themselves have subcommands are not [yet?] supported by Windows Explorer.
This app already supports separators and submenus within submenus; in case support is added in the future.
- Download the latest version from the Releases page.
- Unzip the file and execute
Install.ps1orInstall.bat.
Important
During installation:
- If the Windows settings opens, enable Developer Mode before continuing.
- Confirm the installation of the digital certificate when prompted.
After installation:
- You may need to restart Windows Explorer for the commands to appear. 1
Note
Make sure you have the following installed if something appears not to be working:
You may need to install the second one if you are testing the app on Windows Sandbox.
The Install.ps1 file generated by Visual Studio works with powershell.exe.
Try executing Install.bat if you get an error, in case you are using pwsh.exe.
Tip
You can easily check the latest version from within the application:
Below is a brief description of some of the less obvious features.
You can quickly access some help documents directly from within the app.
The configuration is stored in the local folder; there is a button on the UI to open it.
The commands.json file stores all commands; remember to make a backup just in case.
All file paths have their environment-variable strings expanded for the current user.
Relative paths are converted to absolute paths by searching the PATH environment-variable.
Specifies the action to be performed on the file to execute.
The set of available verbs depends on the particular file or folder.
A special verb MsgBox has been added to make it easy to test your commands.
Instead of executing the specified file, it will simply display an informational message.
The RunAs verb is enforced when the user invokes the command while pressing
CTRL+SHIFT. 2
The variables described in the tables below can be specified in some controls.
You can also specify user and system variables; see environment-variables-editor.
The background path is empty in locations such as This PC and Quick Access.
To display the context menu in these locations, enable Unknown in Match type.
| Variable | Description |
|---|---|
%:LOCAL% |
The app's local data folder path. |
%:INSTALL% |
The app's install folder path. |
%:DESKTOP% |
The desktop folder path for the current user. |
%:BACKGROUND% |
The location where the menu is invoked. |
%:ICON% |
The command light/dark icon. |
The following variables can be specified in Title, Command line & Arguments:
| Variable | Description |
|---|---|
%:PARENT% |
The path of the parent path. |
%:PATH% |
The path of the file or directory. |
%:NAME% |
The name of the file or directory. |
%:STEM% |
The filename without the final extension. |
%:EXT% |
The file extension path component. |
The following are the default values for Command line & Arguments:
| Command line | Arguments | W. Directory | Multi mode |
|---|---|---|---|
"%:PATH%" |
N/A | ANY | Off |
%:PATH% |
"%:PATH%" |
ANY | Each |
%:PATH% |
"%:NAME%" |
EMPTY | Join |
%:PATH% |
"%:PATH%" |
NOT EMPTY | Join |
The following variables can be specified in Command line & Arguments:
| Variable | Description |
|---|---|
%:FILE[:<filename>:]% |
Present a dialog box for selecting a single file. |
%:FOLDER[:<filename>:]% |
Present a dialog box for selecting a single folder. |
%:FILESAVE[:<filename>:]% |
Present a dialog box that offers to save a file. |
The operation is aborted and the command is not executed if any of the dialogs are canceled.
The working directory is used as the folder that is always selected when the dialog box is opened.
The filename parameter specifies the default file name that appears when the dialog box is opened.
Examples: %:FILE% %:FOLDER:%:NAME%:% %:FILESAVE:Document.txt:%.
Specifies where the context menu should be displayed.
| Match type | Description |
|---|---|
File |
The selection consists of one or more files. |
Drive |
The selection consists of one or more drives. |
Directory |
The selection consists of one or more folders. |
Unknown |
Unknown location (e.g. This PC and Quick Access) |
Desktop |
The actual desktop; not displayed in the file explorer. |
Background |
The background directory; no files or folders selected. |
Specifies inclusion and exclusion RegEx filters on the name of the selected items.
This is especially useful to display the context menu depending on the file extension.
For example, the following regular expression is for raster images:
\.(jpe?g|gif|tiff?|a?png|webp|avif|jxl)$
Specifies the behavior when multiple items are selected.
| Mode | Description |
|---|---|
Off |
Hide the command if >1 items are selected. |
Each |
Execute the file individually for each selected item. |
Join |
Execute the file once; items are concatenated with a space. |
The arguments are useful when using the Join mode.
For example, if you need to prefix the items with -f:
File:
app.exe
Command line:-xyz %:PATH%
Arguments:-f "%:NAME%"Result for two items:
app.exe -xyz -f "x.txt" -f "y.txt"
If %:PATH% is enclosed in double quotation marks in the command line, the result will be:
# Probably not what you want.
app.exe -xyz "-f "x.txt" -f "y.txt""Therefore, avoid double quotation marks with %:PATH% in the command line when using Each and Join modes .
Caution
Do not modify the commands.json file in the local folder with a text editor;
invalid formatting or incorrect values may cause problems with Windows Explorer.
| Name | Value |
|---|---|
| Icon | imageres.dll 262 |
| File | %ComSpec% |
| Command line | /c mklink /h "%:FILESAVE:%:NAME%.hlnk:%" "%:PATH%" |
| Match type | File |
| Name | Value |
|---|---|
| Icon | shell32.dll 54 |
| File | %ComSpec% |
| Command line | /c mklink "%:FILESAVE:%:NAME%.slnk:%" "%:PATH%" |
| Match type | File |
| Name | Value |
|---|---|
| Icon | imageres.dll 322 |
| File | %ComSpec% |
| Command line | /c mklink /d "%:FILESAVE:%:NAME%.slnk:%" "%:PATH%" |
| Match type | Directory |
| Name | Value |
|---|---|
| Icon | %ProgramFiles%\Windows Defender\MpCmdRun.exe 0 |
| File | %ComSpec% |
| Command line | /k call "%:ICON%" -Scan -ScanType 3 -File "%:PATH%" -DisableRemediation |
| Match type | File Directory |
Stack: WinUI 3, .NET 9 (C#), C++23.
Enable Developer Mode on your system if you haven't already done so.
Install Visual Studio 2026; add the workloads and components required for developing with WinUI & C++.
Download or clone this repository to your local computer, open UserContextMenu.slnx with Visual Studio.
Create a self-signed certificate for app package signing:
- Open
Package.appxmanifestfrom the Solution Explorer in Visual Studio. - Go to the Packaging tab, click Choose Certificate, then click Create...
- Follow the instructions; save the
PFXcertificate and make sure it is selected.
Install the NuGet packages for the UserContextMenuApp project:
Visual Studio → Tools → Options… → NuGet Package Manager
Package Restore
- Allow NuGet to download missing packages.
- Automatically check for missing packages during build.
Increase the Identity version number in Package.Release.appxmanifest if needed.
Select the Release configuration, right click the UserContextMenuApp project and Pack it.