Intro: Basic Batch Command List
Echo off (Stops displaying c:> before every line of code displayed in the command prompt.)
Example:Stops displaying c:>
Echo (Displays a message on the command prompt.)
Example: Displays "Hello world".
Echo Hello world!
Title (Sets the the command prompt title.)
Example: The title is now "Greeting the world".
Title Greeting the world
Cls (Clears all text above and does not display Cls)
Example: Displays "Hello world" then Displays "Bye" With nothing above Bye.)
Echo Hello world Cls Echo Bye
Pause (Pauses the code until a key on the keyboard is pressed and displays " Press any key to continue...".
Echo Hello world Pause echo Bye
Color (Sets the color of the text and background. The first digit is the background the second digit is the text.)
Example: 0 is the background A is the text.
Set (Sets a variable.)
Example: "Name" now equals "Bob".
If (Condition for a variable.)
Example: If the variable "Name" is equal to Bob then it will display "Welcome, Bob" on the command prompt.
If %name%==Bob Echo Welcome, Bob
If not (Condition for a variable.)
Example: If the variable "Name" is NOT equal to Bob then it will display "Your not Bob" on the command prompt.
If not %Name%==Bob echo Your not Bob
Exit (Closes the command prompt)
Example: Closes the command prompt after the pause.
Echo Hello world pause cls Echo Bye pause exit
: (A series of code title)
Example: The class is called "Start" and executes all the commands below it.
:Start Echo off Title Are you Bob? Color 0A Set Name=Bob If %Name%==Bob echo Welcome, Bob If not %Name%==Bob echo Your not Bob Pause Cls Echo Bye Pause exit
Set /a (Sets a variable with a math equation.)
Example: The variable "Number" equals 2.
Set /a Number=1 + 1
Set /p (Asks for user input.)
Example: Displays "What is your name:" and the variable "Name" set to equal whatever you type into the command prompt.)
Set /p Name=What is your name:
Start (Will open a program on your computer or open a Link)
Example 1: Opens up Google Chrome the program.
Example 2: Opens the link to instructables the web site you are on right NOW.