首页 > 解决方案 > 找不到程序时关闭 cmd 的批处理文件

问题描述

我正在编写一个 python 程序,它从用户那里获取输入,然后创建一个批处理文件并打开该程序,我希望如果找不到程序,那么它将该错误返回给 python 并关闭弹出窗口

Windows cannot find 'room'. make sure you type correctly, and then try again.

错误信息

和命令。

我不知道如何解决这个问题。

def batch(text):

    bat_file = open("hello.bat","w")
    bat_file.write("start "+text)
    bat_file.close()
    os.startfile("hello.bat")

正如我上面提到的,我想关闭弹出窗口和 cmd。

标签: python-3.xbatch-file

解决方案


推荐阅读