So I'm trying to make a little Python script that will extract all items out of a folder into its parent directory. The script works fine but I want to add it to the context menu so whenever I right click a folder, it gets listed.
I followed this guide but I had a few problems:
- Only works on files, not folders.
- I get a "This app can't run on your PC" error (probably because of Win10)
Along with those problems, how can I add it to its own section in the context menu?
Best Answer
for your first problem:
Make sure you add the key to the right parent:
HKEY_CLASSES_ROOT\Directory\shell
when you want to right click on a folderHKEY_CLASSES_ROOT\Directory\Background\shell
when you want to right click in the folder windowif you want to add a context entry for files, it's a bit more complicated. You normally add it for specific file-types (specific extensions). If you want to add it for every type, there's
HKEY_CLASSES_ROOT\*
for your second problem:
You need to run the python application with your script as an argument. (and then probably
"%1"
for the file you right clicked on as a second argument) If you start your script by double clicking it or by typing it into a command-window, the system looks for the python application and runs it with your script as an argument.So this is what you need to put into the registry key:
c:\path\to\your\python.exe c:\path\to\yourScript.py "%1"