A while ago I added a script I wrote to the context menu. I haven't needed it for a while kept it around. Today I tried using it again and it didn't work.

I have included an image of the error below. The title and first line are the directory I have selected.

I know for a fact that the path to the command is valid and works as I tested the script in the command prompt.

The error in question

What can I do to fix this error? This is on Windows 10 if that changes anything, and the command is as follows:

python M:\Sped\python\Extract\extract.py "%1"
  • How did you add an script to context menu? Are you talking about window file explorer context menu? Have you used any third-party software to build a script into menu, or have you modified the registry files manually? What is the format of your script file (.bat or .cmd or what)? Where is your script located on the disk?
    – user766703
    Commented Jan 5, 2018 at 7:27
  • @ThePirateBay Added to context menu via. regedit. Have not used third-party software. The other answers can be found in the question.
    – Spedwards
    Commented Jan 5, 2018 at 7:29
  • "The other answers can be found in the question." - I don't see the full path and extension of you script in your question. I see path to python and path to the folder you are passing as the first argument, but you didn't mention the full path to your script.
    – user766703
    Commented Jan 5, 2018 at 7:32
  • @ThePirateBay Script: M:\Sped\python\Extract\extract.py. It is within the question.
    – Spedwards
    Commented Jan 5, 2018 at 7:33
  • Oh, so you don't even have a batch script? You embedded the full command into the registry file? I think it is not a good practice, better create external batch file and add it to registry command, while passing the argument from command to batch file and then from batch file to python. From the information you provided, I cannot tell exactly what is causing the problem, but I'm pretty sure batch script would help.
    – user766703
    Commented Jan 5, 2018 at 7:37

1 Answer 1


If you see that error its likely the folder path is incorrect and/or the shell context menu is having issues with your python script calls.

This is an approach I used successfully to fix the error.

Create the registry file mypthonprog.reg file similar to this:

"Icon"="C:\\Users\\winuser\\AppData\\Local\\Programs\\Python\\Python311\\python.exe ,0"

@="c:\\\\mypath\\\\subfolder\\\\myprog.cmd \"%1\""

The name of your context menu item can be changed from mypthonprog to what you want to use along with changing the icon path if needed.

The path of the command file can be changed to where it lives on your filesystem (preferably permanently).

Create the cmd file myprog.cmd similar to this:

"C:\Users\winuser\AppData\Local\Programs\Python\Python311\python.exe" "c:\mypath\subfolder\mypyprog.py" %1

The path of the python location should be changed to where you have python installed.

Modify the python file mypyprog.py similar to this:

def main():
    # Check if a folder path is passed as an argument
    if len(sys.argv) < 2:
        print("Folder path not provided.")

    folder_path = sys.argv[1]

This makes the python code aware of the folder parameter you are passing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .