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('') + ' %*') John -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Iain Sent: Tuesday, June 12, 2007 10:18 PM To: Discussion of IronPython Subject: Re: [IronPython] Command line What I didn't make clear was that the extra option (in this case the word test) was missing when using the file association. Iain. Martin Maly wrote: > That seems correct. If I read your message correctly, when you run the .py > file directly and rely on the file association, the python file name will get > passed to the ipy.exe as full path. It is consistent with what I am seeing > with simple test using notepad: > > If, from command line I start "x.txt", notepad will launch with the command > line: > > "C:\WINDOWS\system32\NOTEPAD.EXE" D:\Dev\Gen\bin\Debug\x.txt > > Martin > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Iain > Sent: Tuesday, June 12, 2007 9:18 PM > To: Discussion of IronPython > Subject: [IronPython] Command line > > If I associate ipy.exe with *.py files then run the IronPython files > directory I am not seeing any command line argument that I try to pass > in to the script. > > I have a file called cmdline_test.py with the following two lines, > import System > print System.Environment.CommandLine > > If I run "C:\Program Files\IronPython\ipy.exe" cmdline_test.py test I > will get > "C:\Program Files\IronPython\ipy.exe" cmdline_test.py test > > If I run cmdline_test.py test I then get > "C:\Program Files\IronPython\ipy.exe" "C:\Scripts\cmdline_test.py" > > Is this the expected behavior? > > Thanks > > Iain. > _______________________________________________ > users mailing list > users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > users mailing list > users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com