[IronPython] Command line

Graham Bloice graham.bloice at trihedral.com
Wed Jun 13 09:45:10 CEST 2007


John Messerly wrote:
> The reason arguments aren't getting passed is because file associations by default only pass the file name, not any additional arguments. You can see the registry entry for the file association by running the following IPy code:
> 
> # Reads the registry key containing the command to run for .py files
> from Microsoft.Win32 import Registry
> openkey = Registry.ClassesRoot.OpenSubKey
> regkey = openkey(openkey('.py').GetValue('') + r'\shell\open\command')
> print regkey.GetValue('')
> 
> which will print something like: "C:\path\to\ipy.exe" "%1"
> 
> To pass more arguments, you'd have to add "%*" to that registry entry. In Windows XP I think you can do it from Windows Explorer, Tools | Options | File Associations, find .py association and edit it. In Windows Vista I don't know how to fix it besides manually modifying the registry entry, e.g.:
> 
> # Warning: modifies the registry, don't run unless you know what you're doing
> from Microsoft.Win32 import Registry
> openkey = Registry.ClassesRoot.OpenSubKey
> regkey = openkey(openkey('.py').GetValue('') + r'\shell\open\command', True)
> regkey.SetValue('', regkey.GetValue('') + ' %*')
> 

you can also use "assoc" and "ftype" from a command prompt.

"assoc .py" will tell you what filetype is associated with the .py extension,
and "filetype yourfiletype" will show you the open command for that file type.
 As John states above to get extra parms the file type should end with "%*"

-- 
Regards,

Graham Bloice



More information about the Ironpython-users mailing list