2

If I run Hello.pyw

import os
os.system('start hello.exe')

I get a very popup cmd. How do I run this script without cmd popup.

DavidPostill
  • 7,734
  • 9
  • 41
  • 60

1 Answers1

0

Lose start from your command.

According to start MSDN page or start /?:

Starts a separate window to run a specified program or command.

os.system('hello.exe')

Or if instead of hello.exe you need to run a bat/cmd file, use cmd /c (cmd /? for full cmd options):

os.system('cmd /c "hello.bat"')
CristiFati
  • 38,250
  • 9
  • 50
  • 87
  • There's no point in using `cmd /c` with `os.system`. That runs `cmd.exe /c cmd /c "hello.bat"`. Also, both of the commands in this answer still create a temporary console window when run from pythonw.exe (i.e. a .pyw script). `os.system` uses the cmd shell, which is a console program, so Windows automatically creates a console. Using `start` actually creates two console windows if the target (e.g. hello.exe) is also a console program. Instead, use subprocess to hide the console or prevent it from being created, as I [show here](http://stackoverflow.com/a/7006424/205580). – Eryk Sun Jul 08 '16 at 09:00