Thanks to visit codestin.com
Credit goes to github.com

Skip to content

flipeador/user-context-menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User Context Menu

Create custom commands in the modern context menu and enable/disable commands from other apps.

Preview

Releases | Direct Download (v1.0.3) AMD64 ARM64

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.

Installation

  1. Download the latest version from the Releases page.
  2. Unzip the file and execute Install.ps1 or Install.bat.

Important

During installation:

  1. If the Windows settings opens, enable Developer Mode before continuing.
  2. 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:

  • The current version is right below the preview image on this page.
  • The version of the app you have installed is displayed in the window title bar.
  • The app includes a WebView, used for quick help and to navigate to this page.

Documentation

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.

Preview

Verbs

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

https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutew#:~:text=the%20action%20to%20be%20performed

https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shellexecuteinfow#:~:text=the%20action%20to%20be%20performed

Variables

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.

General

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

Dialogs

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:%.

Match type

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.

Match name

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)$

Multi mode

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.

Examples

Create Hard Link

Name Value
Icon imageres.dll 262
File %ComSpec%
Command line /c mklink /h "%:FILESAVE:%:NAME%.hlnk:%" "%:PATH%"
Match type File

Create Symbolic Link (File)

Name Value
Icon shell32.dll 54
File %ComSpec%
Command line /c mklink "%:FILESAVE:%:NAME%.slnk:%" "%:PATH%"
Match type File

Create Symbolic Link (Folder)

Name Value
Icon imageres.dll 322
File %ComSpec%
Command line /c mklink /d "%:FILESAVE:%:NAME%.slnk:%" "%:PATH%"
Match type Directory

Scan with Windows Defender

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

Build

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:

  1. Open Package.appxmanifest from the Solution Explorer in Visual Studio.
  2. Go to the Packaging tab, click Choose Certificate, then click Create...
  3. Follow the instructions; save the PFX certificate 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.

Footnotes

  1. https://learn.microsoft.com/windows/apps/desktop/modernize/integrate-packaged-app-with-file-explorer#restart-file-explorer

  2. https://windowslatest.com/2024/10/29/windows-11-ctrl-shift-can-now-open-start-taskbar-jump-list-items-as-admins