How come Win+R prompt can open Python when it's not in my path?

4

When I use the run prompt in Windows XP Professional (Win+R), and type python.exe or python, it works and greets me with the python prompt.

However, when I start a cmd window, and then type python.exe or python, it doesn't find it.

This is what I expect, as the Python directory (for me, I:\Python31\) is not in my PATH.

How come, then, that if I type python.exe in the Win+R prompt, it works?

Edit: here is a partial output of SET, I removed most irrelevant entries, I'm not sure why is it useful, apart from the PATH variable which I already said doesn't include the Python directory. If you need a particular variable other than these, please ask.

CLIENTNAME=Console
CommonProgramFiles=I:\Program Files\Common Files
ComSpec=I:\WINDOWS\system32\cmd.exe
FP_NO_HOST_CHECK=NO
OS=Windows_NT
Path=I:\WINDOWS\system32;I:\WINDOWS;I:\WINDOWS\system32\WBEM;I:\WINDOWS\system32\WindowsPowerShell\v1.0;I:\Qt\2010.05\mingw\bin;I:\Program Files\CMake 2.8\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1
ProgramFiles=I:\Program Files
PROMPT=$P$G
SESSIONNAME=Console
SystemDrive=I:
SystemRoot=I:\WINDOWS
VBOX_INSTALL_PATH=I:\Program Files\Oracle\VirtualBox\
windir=I:\WINDOWS

houbysoft

Posted 2011-01-03T01:22:48.580

Reputation: 4 276

Could you edit your question to include the output of SET? You may want to edit it so that you name does not appear. – paradroid – 2011-01-03T02:04:20.830

Posted parts of it, not sure how anything else than Path is relevant, do you want a specific variable? – houbysoft – 2011-01-03T02:11:19.690

What's your working directory? – digitxp – 2011-01-03T02:49:46.580

Answers

12

the Run prompt searches a registry path for programs to launch as well as the %path%. Take a look at HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths - you'll likely find a node called "Python.exe" with the default entry pointing to the Python executable. Installers should add registry entries for all main executables here, but the Run prompt is an underappreciated feature, so a lot of developers forget to add this simple step to their installer.

jcrawfordor

Posted 2011-01-03T01:22:48.580

Reputation: 15 203

Never knew about this myself, thanks for the answer! – houbysoft – 2011-01-03T02:54:46.640

2Technically it is ShellExecuteEx() that does the lookup. – user1686 – 2011-01-04T14:18:25.613

1In fact, there are several places in the registry where paths are located, for example HKCR\Applications. One day I should clean them all out. – Synetech – 2011-08-02T05:39:00.180