0

I've been using the os.system command a lot in my latest Python project with some complex Windows CMD commands, but I don't like the Windows cmd window that opens when I'm running the os.system command. Is there a way to make it hidden and run in the background?

Calvin
  • 43
  • 5
  • 2
    Note that `os.system` has been superseded by the [`subprocess`](https://docs.python.org/3/library/subprocess.html) module, which offers a richer interface for launching process in the background. Per the documentation, _"This module intends to replace several older modules and functions: `os.system`, `os.spawn*`"_ – Brian61354270 Jun 23 '20 at 01:15
  • You may be confusing a terminal window and a shell. Which of the two or both do you want to get rid of? – Ulrich Eckhardt Jun 23 '20 at 05:33
  • Yes, now that I'm rereading it yes I agree with you. I meant the windows CMD window that shows up when using the `os.system` command – Calvin Jun 23 '20 at 17:49
  • [This](https://stackoverflow.com/questions/89228/calling-an-external-command-from-python?rq=1) thread is relevant, although not a clean duplicate. The answer by newtover specifically discusses creation flags in Windows. Ultimately, as Brian says `subprocess` is the way to go. – Andrew F Jun 23 '20 at 17:54

0 Answers0