Windows/DOS: double clicking a .py file

Bengt Richter bokr at
Tue Sep 10 03:10:08 CEST 2002

On Mon, 9 Sep 2002 16:17:08 -0700, "David LeBlanc" <whisper at> wrote:

>cmd.exe will accept a flag telling it to stay open after something is run.
>You can create a shortcut along the lines of:
>cmd /K python <args>
You may want to specify full paths, depending on where things are etc.

You can also do _several_ things in the cmd /k line by using "&". E.g., the following

%SystemRoot%\system32\cmd.exe /x /k prompt [$T$H$H$H$H$H$H] $P$G & title MyPy & D:\Python22\python.exe

  - start a new cmd window
  - set the prompt for it so it will show current time and directory, e.g.,
    [17:19] C:\pywk>
  - set the title of the window to MyPy
  - start interactive python
the shortcut also lets you set the working directory. If you have a place you like
to test code, note that by setting the working directory there, everything will be
visible to import, aside from any other startup initialization. Thus you can separate
things by people or project or whatever. When you exit Python, you'll be at a cmd
prompt as specified, and in the working directory specified. Handy.

Don't forget that you can also change the icon associated with whatever you run via
the shortcut. I use the swiss army knife for many of my various "DOS" console shorcuts.
>You could also add this to the cmd shortcut itself if you have one, but that
>generally turns out to be a major pain since all dos-window based apps will
>then leave their windows open.
You mean the file extension association for .bat and .cmd? Yes, that doesn't work out
as a good general thing.
>A nice aspect of using a custom cmd shortcut is that you can set colors and
>fonts and window size just for this app which might help distinguish it if
>you have a lot of dos windows open. You can set the screen buffer height to
>a high number so you can scroll really far back (not a good idea to make the
>screen buffer width greater then the window width though).
A nice thing is that you can change things just for your current session,
using the properties selection from the system (left click title bar icon for it) menu.

>you can type 'help cmd' in a dos window for more info on cmd switches.
>David LeBlanc
>Seattle, WA USA
>> -----Original Message-----
[...] ;-)

Bengt Richter

More information about the Python-list mailing list