hello_world.bat
.PAUSE
to the file, the batch file would simply run its commands and then automatically close. In this case, it would print “Hello World” to the window and then immediately close the Command Prompt window. When you want to quickly run commands without seeing the output, you can omit this. If you’re running several commands, you could place the PAUSE
command in between them.ipconfig /all
to view network information, ping google.com
to see if Google’s servers are responding, and tracert google.com
to run a traceroute to google.com and see if there are any problems on the way.::
is a comment line and won’t be executed. That makes them a useful way to explain what’s happening in the file for anyone you might give it to–or for your future self, who might forget why you put a certain command in there.>>
operator after each command to append its output to the text file. As we’re going to read the output from the text file anyway, we can omit the PAUSE
command.del
command to delete files or the deltree
command to delete directories. Remember, you’re just using the same commands you’d run in a Command Prompt window.