0

I'm using VBS for the SendKeys method, and when I run the file directly, it does just fine. However, when I call the program with my Python program using os.system, it opens a prompt which not only doesn't look how I want it to, but more importantly it takes priority over the window that was previously in the foreground, thereby rendering the keystrokes useless. Any suggestions as to how I might run it without the prompt window?

1 Answer 1

0

This ios the documentation,

os.system(command)¶

Execute the command (a string) in a subshell. This is implemented by calling the Standard C function system(), and has the same limitations. Changes to sys.stdin, etc. are not reflected in the environment of the executed command.

On Unix, the return value is the exit status of the process encoded in the format specified for wait(). Note that POSIX does not specify the meaning of the return value of the C system() function, so the return value of the Python function is system-dependent.

On Windows, the return value is that returned by the system shell after running command, given by the Windows environment variable COMSPEC: on command.com systems (Windows 95, 98 and ME) this is always 0; on cmd.exe systems (Windows NT, 2000 and XP) this is the exit status of the command run; on systems using a non-native shell, consult your shell documentation.

The subprocess module provides more powerful facilities for spawning new processes and retrieving their results; using that module is preferable to using this function. See the Replacing Older Functions with the subprocess Module section in the subprocess documentation for some helpful recipes.

Availability: Unix, Windows.


As you can see it's meant to do this. It also tells you what to read (9 different other ways) to start programs.

And here's the C definition.

ANSI 4.10.4.5 The contents and mode of execution of the string by the system function

The system function executes an internal operating system command, or an .EXE, .COM (.CMD in Windows NT) or .BAT file from within a C program rather than from the command line.

The system function finds the command interpreter, which is typically CMD.EXE in the Windows NT operating system or COMMAND.COM in Windows. The system function then passes the argument string to the command interpreter.

For more information, see system, _wsystem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.