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
  • 22,898
  • 15
  • 55
  • 90

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
  • 3,982
  • 1
  • 13
  • 24