Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
368 views
in Technique[技术] by (71.8m points)

How to automatically close cmd window after batch file execution?

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

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...