opening an exe from Program Files directory in windows

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jan 2009
Posts: 343
Reputation: JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice 
Solved Threads: 63
JasonHippy's Avatar
JasonHippy JasonHippy is offline Offline
Posting Whiz

Re: opening an exe from Program Files directory in windows

 
0
  #11
Sep 29th, 2009
I've just done a bit of digging around on python.org and found this:
http://bugs.python.org/issue1524

Looks like I'm not the first person to come up with this workaround....See the post made by daniel.weyh on the 25th June 2008.

Jas.
If you're into metal, check out my new band at:
http://www.myspace.com/kinasis
Now booking gigs for 2010....
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 18
Reputation: pysup is an unknown quantity at this point 
Solved Threads: 1
pysup pysup is offline Offline
Newbie Poster

Re: opening an exe from Program Files directory in windows

 
0
  #12
Sep 29th, 2009
Originally Posted by JasonHippy View Post
Hope that solves your problem.
Bingo!!! It sure did.. Thanks a lot Jason

I think my googling skills need improvement
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,546
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 174
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: opening an exe from Program Files directory in windows

 
3
  #13
Sep 29th, 2009
This problem has been around for a long time and not just with Python:
  1. # the "Microsoft kludge", quoting a string within a string fixes the
  2. # space-in-folder-name problem, tells the OS to use the whole string
  3. # including spaces as a single command
  4. # (make sure filename does not contain any spaces!)
  5. os.system('"C:/Program Files/IrfanView/i_view32.exe" ' + filename)
drink her pretty
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 343
Reputation: JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice 
Solved Threads: 63
JasonHippy's Avatar
JasonHippy JasonHippy is offline Offline
Posting Whiz

Re: opening an exe from Program Files directory in windows

 
0
  #14
Sep 29th, 2009
Originally Posted by Ene Uran View Post
  1. os.system('"C:/Program Files/IrfanView/i_view32.exe" ' + filename)
Dammit...I thought I'd tried that combination of string in string earlier..... Obviously that was one permutation I missed!

Hang on....Looking back at my failed scripts from when I was playing around, I had the " and the ' the wrong way around! Damn these fat drummer fingers! grrr! heh heh!

Thanks for that Ene! Yes that's far better than my solution!

Cheers for now,
Jas.
If you're into metal, check out my new band at:
http://www.myspace.com/kinasis
Now booking gigs for 2010....
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,546
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 174
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: opening an exe from Program Files directory in windows

 
0
  #15
Sep 29th, 2009
This is often referred to as the little-known "Microsoft kludge"
drink her pretty
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 406
Reputation: leegeorg07 is an unknown quantity at this point 
Solved Threads: 31
leegeorg07's Avatar
leegeorg07 leegeorg07 is offline Offline
Posting Pro in Training

Re: opening an exe from Program Files directory in windows

 
0
  #16
Sep 29th, 2009
just thinking... wouldnt it have made more sense to just change "Program files" to "Program_files" or something similar?
don't judge me because I'm a year 8!

'it is better to fight for something than to live for nothing'General George S Patton
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 343
Reputation: JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice 
Solved Threads: 63
JasonHippy's Avatar
JasonHippy JasonHippy is offline Offline
Posting Whiz

Re: opening an exe from Program Files directory in windows

 
0
  #17
Sep 29th, 2009
Originally Posted by leegeorg07 View Post
just thinking... wouldnt it have made more sense to just change "Program files" to "Program_files" or something similar?
Not really, because in MS Windows the 'Program Files' folder is the system default folder for programs to be installed in (and there are usually a lot of programs installed there!).

Simply renaming the 'Program Files' folder to 'Program_Files' would cause most (if not all) of your programs to either malfunction, or not work at all when you tried to run them.
The OS probably wouldn't take it too well either!

Plus any shortcuts you have for any programs in the 'Program Files' folder will also stop working...(e.g. desktop shortcuts and start menu links)

So in this case...No! Changing the folder name would definitely not be the best option. Ene's line of code is by far the best solution to the problem!

Cheers for now,
Jas.
If you're into metal, check out my new band at:
http://www.myspace.com/kinasis
Now booking gigs for 2010....
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,546
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 174
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: opening an exe from Program Files directory in windows

 
0
  #18
Sep 29th, 2009
Something only Microsoft could dream up. I understand that in the European version of Windows the space is avoided. The kludge itself is from a programmer within Microsoft.
drink her pretty
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 406
Reputation: leegeorg07 is an unknown quantity at this point 
Solved Threads: 31
leegeorg07's Avatar
leegeorg07 leegeorg07 is offline Offline
Posting Pro in Training

Re: opening an exe from Program Files directory in windows

 
0
  #19
Sep 29th, 2009
nope, in the eu version it still has the space... at least for me
don't judge me because I'm a year 8!

'it is better to fight for something than to live for nothing'General George S Patton
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 113
Reputation: ov3rcl0ck is an unknown quantity at this point 
Solved Threads: 16
ov3rcl0ck ov3rcl0ck is offline Offline
Junior Poster

Re: opening an exe from Program Files directory in windows

 
0
  #20
Sep 29th, 2009
Its actually not as tough as people are making it out to be, if you have a space you need to put ' ' or " " around it to clarify that it has a space, maybe try this:
  1. import os
  2. os.system("'C:\Winamp\Winamp.exe'")

I may be wrong, i might have just been using Linux too long
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum


Views: 1012 | Replies: 22
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC