KillSpammer
12-26-2010, 12:22 PM
Welcome to my tutorials for Batch a sort of programming language to execute DOS commands by creating a .bat file and putting commands in it, since i'm bored and i feel like becoming more active on this community i'll be doing tutorials.
First off lets start off how to actually create a .bat file(Batch doesn't work on anything other than windows)
First open notepad and put this in the notepad.
@echo off
echo Hello World!
pause
and then save as hello.bat and run it the output should be Hello World!
You have created a batch program!
Now lets have a look at what we did there.
@ - Basically stops the next command from showing on the screen.
@echo off - Combined with the @ it turns off all future commands and doesn't show it turning off.
echo - Displays a message on the screen which in this case is Hello World!
pause - Pauses the program until it receives a key press.
Now on to creating a loop
@echo off
:loop
echo Hello World!
goto loop
When you open it you should get a black screen spamming Hello World!
Just close it to stop it
: - This is confirm it as a loop the actual "loop" after this is just a random name and can be used for the goto command
goto - For example goto loop goes to the :loop and and continues from there for example if i had :random then some kind of code under that it would execute from that down until it is directed elsewhere.
Now i think we can continue to user input.
First of all you will need a place to store your input so we put this code in
@echo off
set input=0
set /p input=
if %input% equ 1 goto message
if %input% gtr 1 goto other
:message
echo Hello
pause
:other
echo You put a number higher than 1
pause
So if you put 1 in the input you will get "Hello"
and anything above 1 you will get the other message.
set - Can either create or edit a varriable
set input=0 - The actual name "input" isn't a required name its just for naming it.
set /p input= - You can have any text after the equal sign for example you will have : and whatever the user types will appear beside the :
if %input% gtr 1 goto message - The %input% is the name of the Input varriable and the equ or gtr sign is Equal or Greater than.
If noone is actually using them i will stop since theres no point in doing them without people reading it.
First off lets start off how to actually create a .bat file(Batch doesn't work on anything other than windows)
First open notepad and put this in the notepad.
@echo off
echo Hello World!
pause
and then save as hello.bat and run it the output should be Hello World!
You have created a batch program!
Now lets have a look at what we did there.
@ - Basically stops the next command from showing on the screen.
@echo off - Combined with the @ it turns off all future commands and doesn't show it turning off.
echo - Displays a message on the screen which in this case is Hello World!
pause - Pauses the program until it receives a key press.
Now on to creating a loop
@echo off
:loop
echo Hello World!
goto loop
When you open it you should get a black screen spamming Hello World!
Just close it to stop it
: - This is confirm it as a loop the actual "loop" after this is just a random name and can be used for the goto command
goto - For example goto loop goes to the :loop and and continues from there for example if i had :random then some kind of code under that it would execute from that down until it is directed elsewhere.
Now i think we can continue to user input.
First of all you will need a place to store your input so we put this code in
@echo off
set input=0
set /p input=
if %input% equ 1 goto message
if %input% gtr 1 goto other
:message
echo Hello
pause
:other
echo You put a number higher than 1
pause
So if you put 1 in the input you will get "Hello"
and anything above 1 you will get the other message.
set - Can either create or edit a varriable
set input=0 - The actual name "input" isn't a required name its just for naming it.
set /p input= - You can have any text after the equal sign for example you will have : and whatever the user types will appear beside the :
if %input% gtr 1 goto message - The %input% is the name of the Input varriable and the equ or gtr sign is Equal or Greater than.
If noone is actually using them i will stop since theres no point in doing them without people reading it.