| | |
opening an exe from Program Files directory in windows
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 18
Reputation:
Solved Threads: 1
Hi All,
I need to open a exe from python. For ex i used
but I need to open an exe from the "Program Files" directory. I get an error because of the space between "Program" and "Files".
Anybody has the solution. It must be simple but I am not able to get it
I need to open a exe from python. For ex i used
Python Syntax (Toggle Plain Text)
import os os.system("C:\Winamp\Winamp.exe")
but I need to open an exe from the "Program Files" directory. I get an error because of the space between "Program" and "Files".
Python Syntax (Toggle Plain Text)
import os os.system("C:\Program Files\Winamp\Winamp.exe") >>'C:\Program' is not recognized as an internal or external command.
Anybody has the solution. It must be simple but I am not able to get it
•
•
•
•
Hi All,
Python Syntax (Toggle Plain Text)
import os os.system("C:\Program Files\Winamp\Winamp.exe") >>'C:\Program' is not recognized as an internal or external command.
Anybody has the solution. It must be simple but I am not able to get it
Python Syntax (Toggle Plain Text)
import os os.system("C:\\Program\ Files\\Winamp\\Winamp.exe")
•
•
Join Date: Sep 2009
Posts: 18
Reputation:
Solved Threads: 1
I tried
I get the same error
Python Syntax (Toggle Plain Text)
os.system("C:\\Program\ Files\\Winamp\\Winamp.exe") os.system("C:\\Program/ Files\\Winamp\\Winamp.exe")
I get the same error
try:
Im not sure if defining it as a raw variable would work but its worth a shot
python Syntax (Toggle Plain Text)
temp_var=r("C:\Program files\Winamp\Winamp.exe") os.system(tempvar)
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
'it is better to fight for something than to live for nothing'General George S Patton
Maybe
might be silly, but who knows...
python Syntax (Toggle Plain Text)
os.system("\"C:\Program Files\Winamp\Winamp.exe\"")
•
•
Join Date: Sep 2009
Posts: 18
Reputation:
Solved Threads: 1
•
•
•
•
It's not possible that you don't actually have Winamp in Program Files? You said that you tested with C:\Winamp\Winamp.exe which worked?
If it were not present then the error would be "The System cannot find the path specified"
but I get an error 'C:\Program' is not recognized as an internal or external command.
Maybe i should reinstall my program out of program files folder but i want to do it as a last resort
Last edited by pysup; Sep 29th, 2009 at 9:12 am. Reason: missed detail
It took a bit of playing around, but think I've found a workaround for this....
I noticed in the docs for os.system() (Yes I RTFM!) it mentions that the subprocess.call() should be used instead.
So I had a go with subprocess.call() but I soon ran into very similar problems, it still didn't like the spaces in the path.
After a bit of playing around and using a bit of lateral thinking I decided to try using subprocess.call() to call 'cmd.exe' passing it the path to a program in 'Program Files' as a parameter.
Now, I don't have winamp installed on my pc, so I decided to try and fire up Audacity using the following code:
And you know what?? It bloody works!
After that, I decided to try using os.system in exactly the same way (use it to fire up cmd.exe with the path to Audacity as a parameter):
Guess what??
That worked too!
Woot woot!
You'll get a little cmd window that will pop-up alongside whatever program you fire up, but it will disappear when you close the program down again.
So, all you need to do is copy one of the bits of code posted above and then replace my path to Audacity with the path to your installation of Winamp!
Hope that solves your problem.
Cheers for now,
Jas.
I noticed in the docs for os.system() (Yes I RTFM!) it mentions that the subprocess.call() should be used instead.
So I had a go with subprocess.call() but I soon ran into very similar problems, it still didn't like the spaces in the path.
After a bit of playing around and using a bit of lateral thinking I decided to try using subprocess.call() to call 'cmd.exe' passing it the path to a program in 'Program Files' as a parameter.
Now, I don't have winamp installed on my pc, so I decided to try and fire up Audacity using the following code:
PYTHON Syntax (Toggle Plain Text)
import subprocess subprocess.call(r'C:\WINDOWS\system32\cmd.exe /C "C:\Program Files\Audacity\audacity.exe"')
And you know what?? It bloody works!
After that, I decided to try using os.system in exactly the same way (use it to fire up cmd.exe with the path to Audacity as a parameter):
PYTHON Syntax (Toggle Plain Text)
import os os.system(r'C:\WINDOWS\system32\cmd.exe /C "C:\Program Files\Audacity\audacity.exe"')
That worked too!
Woot woot!

You'll get a little cmd window that will pop-up alongside whatever program you fire up, but it will disappear when you close the program down again.
So, all you need to do is copy one of the bits of code posted above and then replace my path to Audacity with the path to your installation of Winamp!
Hope that solves your problem.
Cheers for now,
Jas.
Last edited by JasonHippy; Sep 29th, 2009 at 9:32 am. Reason: smelling pistakes!
There are 10 types of people in this world.....
Those who understand binary .....
And those who don't!
Those who understand binary .....
And those who don't!
![]() |
Similar Threads
- Rundll.exe error, Not respodning when closing windows XP (Viruses, Spyware and other Nasties)
- Cannot find Windows Explorer (Windows NT / 2000 / XP)
- winupdate.exe problem (Viruses, Spyware and other Nasties)
- RunTime error C++ C: \Program Files|MusicmatchJukebox\mm_tray exe (Viruses, Spyware and other Nasties)
- Internet Explorer & Windows Explorer (desktop shortcuts) Won't Load! (Viruses, Spyware and other Nasties)
- I have this c:\windows\system32\z14.exe HELP!!!!!! (Viruses, Spyware and other Nasties)
- Error loading C:\WINNT\Downloaded Program Files\bridge.dll (Viruses, Spyware and other Nasties)
- Error loading C:\WINDOWS\Downloaded Program Files\bridge.dll (Viruses, Spyware and other Nasties)
- rundll error loading C:\PROGRA~1\INTERN~3\inetkw.dll (Viruses, Spyware and other Nasties)
- "WINDOWS\ SYSTEM\ BRIDGE.DLL" (Viruses, Spyware and other Nasties)
Other Threads in the Python Forum
- Previous Thread: Text Files
- Next Thread: Cookies
| Thread Tools | Search this Thread |
abrupt ansi anti apache approximation array assignment avogadro backend beginner binary book builtin calculator character code converter countpasswordentry curved customdialog dan08 dictionaries dictionary dynamic examples exe file float format function gnu graphics gui heads homework import inches input java launcher library line lines linux list lists loop mouse mysql mysqlquery number numbers numeric output parsing path phonebook plugin pointer port prime programming progressbar projects py2exe pygame pysimplewizard python random recursion redirect scrolledtext software statictext statistics string strings sum table terminal text textarea thread threading time tlapse trick tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable wordgame write wxpython xlib





