Open Folder in Desktop

Jimmy Retzlaff jimmy at
Tue Jan 25 03:32:16 EST 2005

Kamilche wrote:
> Is there a command you can execute in Python that will open a window
> the desktop, such as 'My Documents'? Kind of like 'system', but for
> folder names, not just programs. I'm running on Windows 2000.

There are two issues here. The first is how to open a folder and the
second is how to resolve "special" folders. Folders are "documents"
typically associated with the explorer.exe application. To open a
document with its default app (e.g., a folder), use os.startfile which
is included in Python. For example:

import os

Folders like My Documents, My Pictures, etc. are special and you need to
determine their actual path before you can open them. The pywin32
( include a
way to get at this:

from import shellcon, shell
path = shell.SHGetFolderPath(0, shellcon.CSIDL_MYPICTURES, 0, 0)

Google for CSIDL to find the constants to use for other special folders.


More information about the Python-list mailing list