def run_win_cmd(cmd):
    result = []
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=
    subprocess.PIPE)
for line in process.stdout:
    result.append(line)
Running windows shell commands with python