0

I am trying to open a new command prompt and resume in my desktop app (my app has an "open command prompt here" button). But I cant get it to work: Either the execution of my app halts until I close the command window or the command window just pipes and nothing is shown. This some of what I've tried:

# does nothing, just the execution halts
process = subprocess.run(['cmd.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# Opens the cmd prompt, but execution halts until I close it.
process = subprocess.run(['start'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

So how to do this with the subprocess module? I don't want to use legacy functions, the doc states, that I should use this module instead of os.system and os.spawn* (I'm using Python 3.5)

sydd
  • 1,824
  • 2
  • 30
  • 54
  • is the typo intentional? `['start']`, ... – Rápli András Jan 10 '17 at 22:10
  • @RápliAndrás ops, no – sydd Jan 10 '17 at 22:11
  • @sydd Does that duplicate address your issue? It sounds like you just want a non-blocking subprocess call. Is that correct? – skrrgwasme Jan 10 '17 at 22:21
  • @skrrgwasme Kinda... I am opening lots of stuff with a subprocess.run(), I dont understand why can I open e.g. windows Explorer and its non-blocking, and why cant I do the same with a command prompt – sydd Jan 10 '17 at 22:48
  • @sydd That does sound odd, but I suspect it's related to windows explorer, not your Python code. `subprocess.run()` is indeed a blocking call, so it's explorer that's doing something odd. Your code is doing what it's supposed to do. – skrrgwasme Jan 10 '17 at 23:11

0 Answers0