batch-filecmd

How to automatically close cmd window after batch file execution?


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

start C:\Users\Yiwei\Downloads\putty.exe -load "MathCS-labMachine1"
"C:\Program Files (x86)\Xming\Xming.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.


Solution

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

    start C:\Users\Yiwei\Downloads\putty.exe -load "MathCS-labMachine1"
    start "" "C:\Program Files (x86)\Xming\Xming.exe" :0 -clipboard -multiwindow
    

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