943,724 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 2310
  • Python RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Sep 29th, 2009
0

Re: opening an exe from Program Files directory in windows

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.
Reputation Points: 590
Solved Threads: 123
Practically a Master Poster
JasonHippy is offline Offline
672 posts
since Jan 2009
Sep 29th, 2009
0

Re: opening an exe from Program Files directory in windows

Click to Expand / Collapse  Quote originally posted by JasonHippy ...
Hope that solves your problem.
Bingo!!! It sure did.. Thanks a lot Jason

I think my googling skills need improvement
Reputation Points: 10
Solved Threads: 3
Newbie Poster
pysup is offline Offline
18 posts
since Sep 2009
Sep 29th, 2009
3

Re: opening an exe from Program Files directory in windows

This problem has been around for a long time and not just with Python:
python Syntax (Toggle Plain Text)
  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)
Reputation Points: 625
Solved Threads: 211
Posting Virtuoso
Ene Uran is offline Offline
1,704 posts
since Aug 2005
Sep 29th, 2009
0

Re: opening an exe from Program Files directory in windows

Click to Expand / Collapse  Quote originally posted by Ene Uran ...
python Syntax (Toggle Plain Text)
  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.
Reputation Points: 590
Solved Threads: 123
Practically a Master Poster
JasonHippy is offline Offline
672 posts
since Jan 2009
Sep 29th, 2009
0

Re: opening an exe from Program Files directory in windows

This is often referred to as the little-known "Microsoft kludge"
Reputation Points: 625
Solved Threads: 211
Posting Virtuoso
Ene Uran is offline Offline
1,704 posts
since Aug 2005
Sep 29th, 2009
0

Re: opening an exe from Program Files directory in windows

just thinking... wouldnt it have made more sense to just change "Program files" to "Program_files" or something similar?
Reputation Points: 35
Solved Threads: 32
Posting Pro in Training
leegeorg07 is offline Offline
428 posts
since Jul 2008
Sep 29th, 2009
0

Re: opening an exe from Program Files directory in windows

Click to Expand / Collapse  Quote originally posted by leegeorg07 ...
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.
Reputation Points: 590
Solved Threads: 123
Practically a Master Poster
JasonHippy is offline Offline
672 posts
since Jan 2009
Sep 29th, 2009
0

Re: opening an exe from Program Files directory in windows

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.
Reputation Points: 625
Solved Threads: 211
Posting Virtuoso
Ene Uran is offline Offline
1,704 posts
since Aug 2005
Sep 29th, 2009
0

Re: opening an exe from Program Files directory in windows

nope, in the eu version it still has the space... at least for me
Reputation Points: 35
Solved Threads: 32
Posting Pro in Training
leegeorg07 is offline Offline
428 posts
since Jul 2008
Sep 29th, 2009
0

Re: opening an exe from Program Files directory in windows

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:
Python Syntax (Toggle Plain Text)
  1. import os
  2. os.system("'C:\Winamp\Winamp.exe'")

I may be wrong, i might have just been using Linux too long
Reputation Points: 35
Solved Threads: 22
Junior Poster
ov3rcl0ck is offline Offline
113 posts
since Sep 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Text Files
Next Thread in Python Forum Timeline: Cookies





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC