shell-context-menu

Add a context menu item command on Windows

Usage no npm install needed!

<script type="module">
  import shellContextMenu from 'https://cdn.skypack.dev/shell-context-menu';
</script>

README

NPM

node-shell-context-menu

Add a context menu item command on Windows

Install

npm i shell-context-menu

Usage

const shellContextMenu = require('shell-context-menu');

const options = {
    name: 'MyApp',
    command: 'C:\\MyPath\\MyApp.exe --open'
};

await shellContextMenu.registerOpenWithCommand(['.jpeg', '.png'], options);

Note: It will add the file/folder as argument at the end of the command

registerCommand

Create a context menu item on files

const options = {
    name: 'Explorer',
    icon: 'C:\\Windows\\explorer.exe', // You can specify a path to an ico file or directly put the path of your app and it will automatically find the icon
    command: 'C:\\Windows\\explorer.exe',
    menu: 'Open with Explorer'
};

await shellContextMenu.registerCommand(options);

registerDirectoryCommand

Create a context menu item only on folders

const options = {
    name: 'Explorer',
    icon: 'C:\\MyPath\\icon.ico', // You can specify a path to an ico file or directly put the path of your app and it will automatically find the icon
    command: 'C:\\Windows\\explorer.exe',
    menu: 'Open with Explorer'
};

await shellContextMenu.registerDirectoryCommand(options);

registerOpenWithCommand

Create a context menu item OpenWith on specific filetypes

const options = {
    name: 'Explorer',
    command: 'C:\\Windows\\explorer.exe'
};

await shellContextMenu.registerOpenWithCommand(['.jpeg', '.png'], options);

removeCommand

Remove a named command

await shellContextMenu.removeCommand('Explorer');

removeDirectoryCommand

Remove a named directory command

await shellContextMenu.removeDirectoryCommand('Explorer');

removeOpenWithCommand

Remove a named OpenWith command for given filetypes

await shellContextMenu.removeOpenWithCommand(['.jpeg', '.png'], 'Explorer');