Windows Nt directory names
Bengt Richter
bokr at oz.net
Sun Nov 17 05:03:58 EST 2002
On Sat, 16 Nov 2002 23:30:39 -0800 (PST), asdfasd asdfasdf <s802645999 at yahoo.com> wrote:
>--0-2059518693-1037518239=:31278
>Content-Type: text/plain; charset=us-ascii
>
>
>hi
>
>i wanted to execute a command somewhere in "program files" directory but can't seem to do it as it says : "c:\program" is not recognized as an internal command
>
>i have used :
>
>import os
>
>CMD = r'c:\program files\action.exe'
>
>os.system(CMD)
>
>how do i code so that the space in "program files" is recognized?
>
>thanks
This format will probably make your python script wait until the other program exits:
>>> CMD = r'"C:\Program Files\Windows NT\Accessories\wordpad.exe"'
>>> os.system(CMD)
0
This format uses start to run it separately:
>>> CMD2= r'"start """C:\Program Files\Windows NT\Accessories\wordpad.exe""'
>>> os.system(CMD2)
0
The trick is in how double quotes get handled as the line is passed along.
CMD2 should be equivalent to typing
start "C:\Program Files\Windows NT\Accessories\wordpad.exe"
at the console window prompt, unless I goofed ;-)
Regards,
Bengt Richter
More information about the Python-list
mailing list