python at command prompt

Ton van Vliet sheep.in.herd at green.meadow
Mon Nov 5 08:20:45 EST 2007


On Mon, 05 Nov 2007 11:03:36 +1100, "[david]" <david at nospam.spam>
wrote:

>Tim Roberts wrote:
>> Ton van Vliet <sheep.in.herd at green.meadow> wrote:
>>> There's could also be an issue with entering 'python' at the command
>>> line, and not 'python.exe'. Once the PATH is setup correctly, try to
>>> enter 'python.exe', and check whether that works.
>>>
>>> IMHO, to get any 'program-name' (without the .exe extension) to work,
>>> one needs to:
>>> 1. register the executable with windows (doesn't work for python) or
>>> 2. make sure the the PATHEXT environment variable is set correctly,
>>> and includes the .EXE extension (on my w2k system it looks like:
>>> .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH)
>> 
>> You're confusing two things here.  Executables (.exe) are always available,
>> and do not need to be registered to be run without the extension.
>> 
>> It is possible to have Windows execute "abc.py" when you type "abc", and
>> that DOES require registering the .py extension and adding .py to the
>> PATHEXT environment variable.
>> 
>> A very useful thing to do, by the way.  I have many command line tools for
>> which I have forgotten whether they are batch files, small executables, or
>> Python scripts.  And that's how it should be.
>
>That is,
>
>"Executables (.exe) are always available,"
>... provided that the PATHEXT environment variable
>has not been set incorrectly...

Right

>and
>"Executables ... do not need to be registered"

Right also, however they may be 'registered' to get a 'similar' kind
of response:

If you have a look at the following registry key:
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths
you may find several 'registered' applications that can be launched
without appending the .exe extension from the 'start|run' menu

If you want to experiment for yourself: (needless to say: be carefull)

1. Select a small stand-alone .exe application of your choice
2. *copy* the .exe into some directory that is not on your PATH (e.g.
d:\temp)
3. Rename the application (e.g. to 'eppo.exe')
4. Open regedit and add an 'eppo.exe' to the above mentioned 'App
Paths' key
5. Modify its (Default) value to 'd:\temp\eppo.exe'

>From now on you can just enter 'eppo' at 'Start|Run' entry field, to
launch the application

To make entering 'eppo' working at the command prompt, the directory
in which the eppo.exe is located must be in the (search) PATH, even if
the PATHEXT is *not* setup correctly.

If the applications directory is not on your PATH, you may still start
it with 'start eppo'

I definitely am not an expert in this area, so may someone else may
come with a better explanation of this .exe registering stuff, I'm
sure there's more involved (like setting of the 'open with' keys,
registering COM servers, etc) but I just wanted to bring up that
'registering' executables is not *that* uncommon.

HTH ;-)
-- 
Ton



More information about the Python-list mailing list