I was also confused as to why we're adding a cmd
at the beginning and I was wondering if I had to open the command prompt first.
What you need to do is type the full command along with cmd /k
. For example assume your batch file name is "my_command.bat" which runs the command javac my_code.java
then the code in your batch file should be:
cmd /k javac my_code.java
So basically there is no need to open command prompt at the current folder and type the above command but you can save this code directly in your batch file and execute it directly.