How do I hide the console when I use os.system() or subprocess.call()?

Viewed 71087

I wrote some statements like below:

os.system(cmd) #do something
subprocess.call('taskkill /F /IM exename.exe')

both will pop up a console.

How can I stop it from popping up the console?

5 Answers

Just add: subprocess.call('powershell.exe taskkill /F /IM exename.exe', shell=True)

Try to change the extension from .py to .pyw

Its basically just a Python User Interface file. So it opens up a new Window without the command line. chech this link (filext.com/file-extension/PYW)

Related