0

The python documentation for this is very dry, I was wondering if you guys could help me.

My goal is to make python execute commands that I would normally execute in the command prompt. (I'm running windows)

If I run

import subprocess
proc = subprocess.Popen("C:\Windows\system32\cmd.exe")

It opens the command prompt. Is there a way to get the program to write in something like "dir C"?

The Entramanure
  • 19
  • 1
  • 1
  • 5

1 Answers1

0

You can use the os library:

import os
os.system('dir C')

If you want to open a new command prompt and run a command in it, then I can't help you there. I tried to figure that out for macOS a while ago to no avail.

ejj28
  • 88
  • 2
  • 12