Re: [IronPython] Command line

2007-06-13 Thread Graham Bloice
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
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] Command line

2007-06-12 Thread Iain
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


Re: [IronPython] Command line

2007-06-12 Thread Iain
Looks like I've worked it out for myself.  It looks like that is the 
behavior you will get if you use the 'Always open with this 
applications' option when you use 'Open With..'

I fixed it by undoing that change and changing what was run for all 
Python.File types.

Iain.

Iain wrote:
 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


Re: [IronPython] Command line

2007-06-12 Thread Martin Maly
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


Re: [IronPython] Command line

2007-06-12 Thread Iain
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


Re: [IronPython] Command line

2007-06-12 Thread John Messerly
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