0

I'm very new to python.

I wanted to make a Python File (script) that would run cmd and then run a Command for example: net user. I tried this

import os
os.system ('start cmd')

but I still need help.

Federico klez Culloca
  • 24,336
  • 15
  • 57
  • 93

1 Answers1

1

You can use subprocess:

import subprocess
import sys

command = "net user"
subprocess.call(command,shell=True,stdout=sys.stdout)

Example output:

User accounts for \\COMPUTER

-------------------------------------------------------------------------------
user1                    user2                    user3                 
The command completed successfully.
glhr
  • 4,152
  • 1
  • 14
  • 24