473,938 Members | 13,717 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Special Folders (ie Desktop location)

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.CreateO bject("WScript. Shell")
msgbox WSHShell.Specia lFolders("Deskt op")

TIA,

Colin
Jul 18 '05 #1
1 5278
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.CreateO bject("WScript. Shell")
msgbox WSHShell.Specia lFolders("Deskt op")


Use COM:
from win32com.client import Dispatch
w = Dispatch('WScri pt.Shell')
w.SpecialFolder s('Desktop')

u'C:\\Documents and Settings\\Colin \\Desktop'

-Peter

P.S.: Yes, I edited the result to look like yours might. ;-)
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2866
by: Paul Lyons | last post by:
Hi, I'm developing on WinXP and deploying on W2K so the path to System32 directory is different on each system. I'm trying to import DLLs from the Win32 API, but I have to change the path and recompile before punching things up to the server. private const string SYSTEM32_PATH = @"C:\Winnt\System32 \"; // Or locally @"C:\Windows\System32\";
2
10015
by: Bill English | last post by:
I want the initial directory of my save file dialog to be the My Documents folder. I know that that can vary, so is there a class that contains these special folder? What I would like is OpenFileDialog.InitialDirectory = Class.MyDocuments
1
1813
by: news.microsoft.com | last post by:
I'm researching ways to locate so-called special folders such as "My Documents", "<username>\Application Data", etc. I've found references to Application.CommonAppDataPath(), etc, but those are too limiting. I'm really looking for managed-code equivalents of SHGetFolderPath(). Is there such a beast? Or will I need to do a DLLImport to get the flexibility I need? Cheers, Jon
2
1661
by: Bob Hanson | last post by:
Hello All, I noticed in the ASP.NET beta 2 that we have more special folders. Can I get some clarification regarding these folders? I am just making sure of the intent. Thanks in advance, Bob Hanson
12
1833
by: Quemasda | last post by:
Hi, The application I'm working on should set the Special Folders (Favorites, My Documents, ...) but I can't find the way to do it. So far, I've been able to get the path of those Special Folders but not set them. Does anybody know how? Thanks in advance, Que_Mas_Da.
1
1613
by: Andrea | last post by:
I need to get the description (with the default language of the operating system) for the special system folders like Control Panel, My Computer and so on. I have the CLSID of them and, for example, I launch the control panel typing ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}
3
4311
by: DCC | last post by:
I need to resolve Windows special folders. From what I have read it would seem that using CSIDL's and SHGetSpecialFolderPath and SHGetFolderPath was the way to accomplish that in VB6 and VB.NET. Is this still the best method in VB 2005? If so does anyone have a working example of how to declare and call the functions? I have tried declaring the functions as follows: Private Declare Function SHGetFolderPath Lib "shell32.dll" _ Alias...
12
8043
by: wheels619 | last post by:
How can I get access for another user's special folder locations? A configuration file is stored in the users' appData folder and the program altering it will be ran under the admin.
2
2181
by: Mike P | last post by:
I need to find all the folders at a certain location, and then once I have this list of folders I need to add some of them to a collection and then show the names of those folders on screen (there are certain folders that I do not want show on screen so I need to be able to have a foreach loop once I have all the folder names where I can check for folder names I don't want). Does anybody know how to do this?
0
10133
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9963
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11522
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11104
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8216
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7380
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6073
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6292
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4444
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.