3

[Submitted to superuser two days ago, but nobody could answer it, so reposting here.]

Working on the basis of this post (and this follow-up post), I've tried adding a python script (which I've added to the path and so on, so that I can run it from the command line everywhere in the system) to the context menu, like this:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\get_abs]
@="&Get Abstracts"
"Icon"="%SystemRoot%\\System32\\shell32.dll,71"

[HKEY_CLASSES_ROOT\Directory\Background\shell\get_abs\command]
@="C:\\cmdtools\\get_abs.py"

However, I get a strange error message when I try to run it.

enter image description here

To be clear, I have successfully run this script from the command line (using powershell, in case it matters) in the folder in which I'm trying to run it from the context menu.

5
  • I believe the command key needs to point to an actual executable, e.g. .exe file. Try it with the path to your Python interpreter followed by the script path. Commented May 10, 2016 at 1:18
  • You with a space in between, with the script path like an argument? Commented May 10, 2016 at 1:33
  • Yes, I think so. Might be worth trying anyway. You might also need %1 for the file being passed in (which would go at the end, with another space before it). Commented May 10, 2016 at 1:40
  • That did it! Write your answer as an answer and I'll mark it right. Commented May 10, 2016 at 3:05
  • By the way, I'm totally fascinated by 6502 assem. lang.! :) Commented May 10, 2016 at 3:06

1 Answer 1

5

Python scripts aren't natively executable by Windows; it's complaining that you didn't specify an .exe file. That's easy though, you just specify python.exe. Follow that up with the path to your script and then a %1 -- this is a placeholder for the path to the clicked file. To allow your command to work with paths with spaces in them, surround the %1 with quote marks. Putting it all together, we get:

C:\path\to\python.exe C:\path\to\your\script.py "%1"

BTW, a handy utility for managing context menus is Fast Explorer.

Sign up to request clarification or add additional context in comments.

1 Comment

The script itself doesn't take any arguments (it works on all the files in the folder it's run in), so I don't need the "%1," but thanks for mentioning that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.