Skip to content

Instantly share code, notes, and snippets.

@cianb96
Last active January 21, 2024 00:01
Show Gist options
  • Save cianb96/4423955 to your computer and use it in GitHub Desktop.
Save cianb96/4423955 to your computer and use it in GitHub Desktop.
BATCH BASICS

Check out these websites with great guides for beginners:

http://www.computerhope.com/batch.htm (REAL GOOD)

http://coolhacking-tricks.blogspot.be/2012/01/learn-batch-programming-video-tutorials.html (COMPLICATED)

http://ss64.com/nt/ (SUPERB REFERENCE)

OTHERWISE:

Type the line below in command prompt (cmd) and press enter:

help

This is a list with descriptions of ALL commands in cmd you can use.

If you need more info on a specific command you can type /? at the end of any command and press enter. Here's an example:

color /?

Remember: when writing most commands in a file, keep the entire command on the same line!

A Few Common And Useful Commands:

@echo off

This first one hides all your commands in the console so that whoever opens your file does not see what codes you have used. Here's a good example of how useful this command is. Save this in a file (filename.bat) and run it:

@echo off

echo hi world

echo watsup? how you doing ? trali dadaaaaaaaa

PAUSE

See? It only displays your text you want to output thanks to @echo off. Now just delete that first line from the file and see how different it runs.

Another 2 useful commands are:

:bla

... some of your code here ...

goto bla

This forms a loop between the pointer (:bla) and the return command (goto bla), which can be used for mischief. Just remember that the pointer could be called anything (eg. :nameitlikeyouwant) and you can have as many as you want in a file but you must use the same name when you return to it using goto command.

More Tricks:

start www.google.com

This will start your default web-browser and open the website. This command is usually used to start programs but can equally be used in this manner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment