473,383 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Open Folder in Desktop

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

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


Here are some commands you can use (tested on WinXP, so YMMV):
1. The os.system function

import os
os.system('explorer "c:\program files"')

This has the disadvantage that a cmd.exe windows is also opened,
because os.system executes the command in a subshell.

But using this approach the explorer starts in front of all other windows.
2. The os.startfile function

import os
os.startfile("C:\program files")

Using startfile doesn't open a cmd.exe window, but the folder window
is not started in front of the other windows
3. The subprocess.Popen function

import subprocess
subprocess.Popen('explorer "C:\program files"')

With subprocess.Popen no cmd.exe window is opened and the explorer
starts in front of the other windows.
But the subprocess module is new in Python 2.4.

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


Maybe this is good enough?

os.system("explorer " + folder_path)

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

os.system("start .")

works for me.

regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
Jul 18 '05 #4
Thanks, startfile worked great for me!

Jul 18 '05 #5

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

Similar topics

1
by: Bernavich2004 | last post by:
Ok I am going nuts. This problem ONLY happens when I use a Microsoft Office 2003 product like word, or .NET development IDE. WHen I use the Open file dialog and click on a folder to drill down,...
1
by: DavidS | last post by:
Have XP SP2. Using VS.NET 2003 v7.1.3088, Asp.NET v1.1.4322. For some reason - cannot open file on local machine using window.open command. Sample syntax : window.open("C:\\Downloads\File.txt",...
3
by: Mark | last post by:
I'd like to open up Windows Explorer from my .NET desktop application to a specific path. I essentially want to execute: %Systemroot%\explorer.exe c:\somepath\ How can this be done? Thanks...
2
by: **Developer** | last post by:
I have a folder on my Desktop that has the following properties: Type: Folder Target: \\MM\backup Comment: \\MM\\Backup When I execute: Directory.GetFiles(NewDirectory & "\")
6
by: mardif | last post by:
Hi guys. I've a very big big big problem: I've in my windows computer a file named cicciobello.html, located in c:\documents and settings\username\desktop\cicciobello.html. Now, I MUST open...
0
by: Phil Galey | last post by:
I created a desktop application in VB.NET and in the Setup and Deployment project, under File System on Target Machine, I added a custom folder which is to be added to the Desktop of All Users. To...
1
by: =?Utf-8?B?UmFndQ==?= | last post by:
Hi All I am trying to open a folder ( "D:\screenshots") by clicking a button in the web page, which opens the directory/folder in windows explorer in VS. But if i deploy the same application and...
25
by: Andy_Khosravi | last post by:
I just recently changed my database that I'm running from a monolithic DB to a split FE/BE. The front end resides on the client machine and the BE resides on a network drive. I'm experimenting with...
4
by: mikkoO8 | last post by:
hi. im actually making a desktop cleaner that can move the files and icons to a folder inside the listview box. i can make the listview box filled with files contains at the desktop and i can make...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.