Get Special Folders (ie Desktop location)
Peter Hansen
peter at engcorp.com
Tue Nov 30 10:09:33 EST 2004
Colin Steadman wrote:
> I'm just starting out writing Python scripts (in PSP), and need to
> find the location of Windows special folders such as 'My Documents'
> and 'Desktop' so that I can save files in the right place. Is there
> any method I can use in Python to get these?
>
> If I were doing this in VBScript it'd be:
>
> Dim WSHShell
> Set WSHShell = WScript.CreateObject("WScript.Shell")
> msgbox WSHShell.SpecialFolders("Desktop")
Use COM:
>>> from win32com.client import Dispatch
>>> w = Dispatch('WScript.Shell')
>>> w.SpecialFolders('Desktop')
u'C:\\Documents and Settings\\Colin\\Desktop'
-Peter
P.S.: Yes, I edited the result to look like yours might. ;-)
More information about the Python-list
mailing list