Python scripts from DOS
Dave Angel
davea at ieee.org
Fri Jul 9 08:22:51 EDT 2010
Mark Carter wrote:
> On my machine, I can go to a DOS shell, and type
> myscript.py
> This will cause the script to be run as a python script. So that bit
> works.
>
> On another machine, on which python was set up without admin
> privileges, if I type
> myscript.py
> it will open the "Open With" dialog box. It wont let me execute it
> with python.exe. It asks me the same question every time, too. If I
> type
> python myscript.py
> then everything works fine.
>
> Is there a way of setting up the "other" machine so that it replicates
> the behaviour of my machine?
>
>
Assuming you're talking Windows XP, Vista or Win7 you can do the following:
There are registry settings in two places, hklm and hkcu. If you only
have one user on the machine, it probably doesn't matter. in that case,
there's a nice commandline way to make these associations.
assoc creates associations beteween a file extension and a string
ftype creates an association between that string and an executable
program.
On my machine, assoc .py shows
.py=Python.File
and ftype Python.File shows
python.file="C:\PrgFiles\APYTHO~1\python.exe" "%1" %*
Or you can read the following link:
http://msdn.microsoft.com/en-us/library/ms724475(VS.85).aspx
DaveA
More information about the Python-list
mailing list