Scripting >> Python >> Windows >> How to ensure python .py scripts can parse script arguments correctly

 

Assuming you have Python3 installed into c:\Python3 and that you have installed Windows python launcher in c:\windows

 

Export of registry key HKEY_CLASSES_ROOT\.py looks like:

[HKEY_CLASSES_ROOT\.py]
@="Python.File"
"Content Type"="text/x-python"

[HKEY_CLASSES_ROOT\.py\OpenWithProgIds]

[HKEY_CLASSES_ROOT\.py\ShellNew]
@="Python.File"
"NullFile"=""


Screenshot of Computer\HKEY_CLASSES_ROOT\.py :

 



Export of registry key HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.py :-

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.py]
@="Python.File"
"Content Type"="text/x-python"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.py\OpenWithProgIds]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.py\ShellNew]
@="Python.File"
"NullFile"=""

 

Screenshot of Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.py :-

 

 

Export of registry key  HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command :-

[HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command]
@="\"C:\Python3\python.exe\" \"%1\" %*"

 

Screenshot of ComputerHKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command :-


 

 

assoc setting for .py

C:\Python3>assoc .py
.py=Python.File

 

ftype setting for Python.File

C:\Python3>ftype Python.File
Python.File="C:\WINDOWS\py.exe" "%L" %*