This repository has been archived on 2023-01-27. You can view files and clone it, but cannot push or open issues or pull requests.
cad/ref/context-menu/node-shell-context-menu
2022-10-15 19:16:08 +02:00
..
src for the boyz 2022-10-15 19:16:08 +02:00
test for the boyz 2022-10-15 19:16:08 +02:00
.eslintrc.json for the boyz 2022-10-15 19:16:08 +02:00
.gitignore for the boyz 2022-10-15 19:16:08 +02:00
package.json for the boyz 2022-10-15 19:16:08 +02:00
README.md for the boyz 2022-10-15 19:16:08 +02:00

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');