Python 2.7 and cmd on Windows 7 64 (files lost)
Tim Golden
mail at timgolden.me.uk
Thu Jun 23 03:31:26 EDT 2011
On 23/06/2011 07:33, Michel Claveau - MVP wrote:
> Hi!
>
> (sorry for my bad english...)
>
> On Win 7 64 bits:
> Command-Line
> CD \Python27
> dir C:\Windows\System32\SoundRecorder.exe :==> OK
> Python.exe
>
>>>> import os
>>>> os.system("dir C:\\Windows\\System32\\SoundRecorder.exe")
>
> ==> Do not found the file !!!
>
> and os.system("cmd /k") then "dir C:\Windows\System32\SoundRecorder.exe" do not found
> anyway.
>
> But:
> {Ctrl-Z} in Python
> then dir C:\Windows\System32\SoundRecorder.exe run OK
>
> Therefore, is the problem only in Python?
Certain commands, including "dir" and "copy" are not executables
in their own right, but merely subcommands of cmd.exe. You've
got two options in Python:
os.system (r"cmd /c dir c:\windows")
or:
subprocess.call (["dir", "c:\\windows"], shell=True)
which basically does it for you behind the scenes.
I hope that helps..
TJG
More information about the Python-list
mailing list