Fix: Python Script Arguments Not Passed

by garth on May 4, 2007

On Windows, you can run a Python script on the PATH simply with its name. These should be equivalent: 

c:>congeal blood

c:>congeal.py blood

c:>python congeal.py blood

If it's not working that way, fixing PATHEXT and correcting the file type associations with ASSOC and FTYPE will usually do the trick: 

c:>set PATHEXT=%PATHEXT%:.PY

c:>ftype Python.File="C:Python25python25.exe" "%1" %*

c:>assoc .py=Python.File

If that still isn't working, try deleting the following registry key:

HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.PY

There's plenty of advice about PATHEXT, FTYPE, and ASSOC, but none of the search terms I tried dug up the registry key. I knew there had to be one, because giving FTYPE silly arguments didn't stop the script from being executed. I found the registry key by brute-force searching the registry for .PY. I'm posting this so that someone else can save that hour of hassle.