[python-win32] Issuing a command via subprocess, other methods in Windows 7
Tim Roberts
timr at probo.com
Wed Feb 22 18:59:33 CET 2012
David Hutto wrote:
> initiates the START command, which means it works, but not on command
> line when using SoundRecorder which is in the system32 dir. I thought
> it might be a directory placement problem, but don't know if that
> would be the correct way to fix it, or if that's even the problem.
>
> Any ideas why the above works for the START, and not the
> SoundRecorder, when both work on the windows command prompt when typed
> directly in?
Yes. The one critical piece of information you did not supply here is
that you are running 64-bit Windows 7. That's the root of the problem.
SoundRecorder.exe is a 64-bit executable, and lives in
\Windows\System32. When you are a 32-bit process on 64-bit Windows, and
you try to refer to files in \Windows\System32, the operating system
"helpfully" rewrites the path so you actually refer to
\Windows\SysWOW64, which is where the 32-bit executables and DLLs live.
Unlike almost every other utility, there is no 32-bit version of
SoundRecorder.exe, so subprocess fails to find the executable and dies.
Cmd.exe is a 64-bit process, so it looks in the real System32 and finds it.
So, what are your options? One answer is to install a 64-bit build of
Python. Another answer is to turn off the file system redirection using
ctypes.windll.kernel32.Wow64DisableWow64FsRedirection (I just tried it
-- it works).
By the way, there is no point in using Popen with SoundRecorder. It's a
GUI application. It doesn't use stdin and stdout.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32
mailing list