Making Python scripts run on Windows without specifying ".py" extension Making Python scripts run on Windows without specifying ".py" extension python python

Making Python scripts run on Windows without specifying ".py" extension


Add .PY to PATHEXT as noted before

Then do:

assoc .py=Python.Fileftype Python.File=c:\Python27\python.exe "%1" %*

Adding python to the path isn't necessary to execute the script in a command prompt or double clicking in Explorer, only if you want to start an interactive python session or running the script with python yourscript.py

See http://docs.python.org/2/using/windows.html for more details.


Modify the PATHEXT variable to include Python scripts. For example, here's mine:

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY

You can do this every time you open a command console, or just modify your user global environment variables so that every instance of cmd.exe will include it.