找不到程序时批处理文件关闭cmd

时间:2019-07-17 16:29:13

标签: python-3.x batch-file

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

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

error message

和cmd。

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

def batch(text):

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

如上所述,我想关闭弹出窗口和cmd。

0 个答案:

没有答案