I'm able to run commands through CMD with Python with subprocess.call('insert command here')
but it opens the CMD window then closes right away. Is there a way to not open it at all?
Asked
Active
Viewed 924 times
0

martineau
- 119,623
- 25
- 170
- 301
-
1see https://stackoverflow.com/a/6390817/4004145 – Ofir Gottesman Jun 08 '21 at 21:11
-
1@OfirGottesman: That question is about `subprocess.check_call()` not `subprocess.call()`. – martineau Jun 08 '21 at 21:14
-
It has the same parameter as `subprocess.check_call()`, anyway I'll answer it for `subprocess.call` – Ofir Gottesman Jun 08 '21 at 21:20
1 Answers
1
You can set shell=True
when calling subprocess.call
:
subprocess.call('insert command here', shell=True)

Ofir Gottesman
- 374
- 4
- 11
-
1Do you happen to know why setting `shell=True` suppresses the `cmd` window? It seems to me like it would do the opposite of that… – martineau Jun 09 '21 at 00:15