批处理文件执行后如何自动关闭cmd窗口? [英] How to automatically close cmd window after batch file execution?

查看:38
本文介绍了批处理文件执行后如何自动关闭cmd窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个包含这两行的批处理文件:

I'm running a batch file that has these two lines:

start C:UsersYiweiDownloadsputty.exe -load "MathCS-labMachine1"
"C:Program Files (x86)XmingXming.exe" :0 -clipboard -multiwindow

此批处理文件用于运行 Xming 应用程序和 PuTTY 应用程序,以便我可以通过 SSH 连接到我大学的计算机实验室.

This batch file is used to run the Xming application and then the PuTTY app so I can SSH into my university's computer lab.

但是,如果我运行它并且 Xming 尚未打开,一旦我从 PuTTY 终端退出,cmd 窗口将保持打开状态.只有当我已经运行 Xming 时,cmd 窗口才会在我关闭 PuTTY 终端时关闭.我尝试将 exit 添加到批处理文件的最后一行,但无济于事.

However, if I run this and Xming is not already open, once I exit from the PuTTY terminal the cmd window remains open. Only if I have already run Xming does the cmd window close when I close the PuTTY terminal. I've tried adding exit to the last line of the batch file, but to no avail.

推荐答案

修改批处理文件为START两个程序,而不是STARTing一个和CALL另一个

Modify the batch file to START both programs, instead of STARTing one and CALLing another

start C:UsersYiweiDownloadsputty.exe -load "MathCS-labMachine1"
start "" "C:Program Files (x86)XmingXming.exe" :0 -clipboard -multiwindow

如果你这样运行,程序启动后CMD窗口不会一直打开.

If you run it like this, no CMD window will stay open after starting the program.

这篇关于批处理文件执行后如何自动关闭cmd窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆