How to automatically close cmd window after batch file execution?

后端 未结 8 1625
半阙折子戏
半阙折子戏 2020-11-30 23:47

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)\\Xmi         


        
8条回答
  •  情话喂你
    2020-12-01 00:34

    You normally end a batch file with a line that just says exit. If you want to make sure the file has run and the DOS window closes after 2 seconds, you can add the lines:

    timeout 2 >nul
    exit
    

    But the exit command will not work if your batch file opens another window, because while ever the second window is open the old DOS window will also be displayed.

    SOLUTION: For example there's a great little free program called BgInfo which will display all the info about your computer. Assuming it's in a directory called C:\BgInfo, to run it from a batch file with the /popup switch and to close the DOS window while it still runs, use:

    start "" "C:\BgInfo\BgInfo.exe" /popup
    exit
    

提交回复
热议问题