[python-win32] Issuing a command via subprocess, other methods in Windows 7

Preston Landers planders at gmail.com
Wed Feb 22 16:42:25 CET 2012


I thought "start" wasn't an actual executable but rather a builtin
command of the cmd.exe shell.

Have you tried something like:

scope = subprocess.Popen([r'cmd.exe', '/c start SoundRecorder'],shell
= True, stdout=subprocess.PIPE)

regards,
Preston

On Wed, Feb 22, 2012 at 1:09 AM, David Hutto <smokefloat at gmail.com> wrote:
> Hi,
>
> I'm using:
>
> Microsoft Windows [Version 6.1.7600](Windows 7)
> Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
>
> Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
> win32
>
> I've tried numerous methods trying to send a simple command in a shell session.
>
> When the commands are placed into the windows command prompt directly,
> they issue perfectly fine, but in the below interpreter session
> errors, it finds and utilizes START, as well as other shell commands,
> but not for other types of primary commands that work when typed
> directly int the windows command prompt, such as SoundRecorder(shown
> below).
>
> Below are a few of my unlucky attempts:
>
>>>> scope = subprocess.Popen(["SoundRecorder"],shell = True, stdout=subprocess.P
> IPE)
>>>>
>>>> 'SoundRecorder' is not recognized as an internal or external command,
> operable program or batch file.
>
>>>> scope = os.system("START, SoundRecorder")
>
> The system cannot find the file SoundRecorder.
>
>>>> scope = subprocess.Popen([r'START', 'SoundRecorder'],shell = True, stdout=su
> bprocess.PIPE)
>
>>>> The system cannot find the file SoundRecorder.
>
> scope = subprocess.Popen([r'START', 'C:\Windows\System32\SoundRecorder.exe'],she
> ll = True, stdout=subprocess.PIPE)
>
>>>> The system cannot find the file C:\Windows\System32\SoundRecorder.exe.
>
> Just using START, like below:
>
> scope = subprocess.Popen([r'START',shell =
>  True, stdout=subprocess.PIPE)
>
> 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?
>
>
> Thanks,
> David
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32


More information about the python-win32 mailing list