import subprocess


def RunSubprocess(command):
    # 使用subprocess.Popen执行CMD命令
    # process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
    print(command)
    # process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
    #                            creationflags=subprocess.CREATE_NO_WINDOW, text=True)

    process = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

    # 打印输出和错误信息
    print(process.stdout)  # 输出信息
    print(process.stderr)  # 错误信息

    # 循环读取输出并打印
    # for line in process.stdout:
    #     print(line, end='')

    # 等待进程结束
    # process.wait()
    #
    # # 检查进程是否成功执行
    # if process.returncode == 0:
    #     print("CMD script executed successfully")
    # else:
    #     print("CMD script execution failed")
