简体   繁体   中英

How to open cmd window and run commands in it with a batch file?

Main question: I want to use a batch file to open cmd window so that some commands are run on that new opened window. How do I do that?

To be more precise I want to make batch file which would open a cmd window, compile Java code and run the application (using commands listed in the batch file) so I could see some application output in the window and when application closes cmd window should stay open. Saying this because I don't know if there are specific/useful use cases conserning Java.

Have your batch file call another batch file with & at the end. The second file will have to know to wait before closing.

ex:
file1.bat

echo "hi"
.\file2.bat &
echo "bye"
"read user input"

file2.bat

echo "hello"
"read user input"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM