Basic Batch [TUT]

View previous topic View next topic Go down

Basic Batch [TUT]

Post by Logic_Bomb on Tue May 12, 2009 8:17 pm

Recently I have been thinking that A few batch tutorials would be helfull to the forum.
So here is my first tutorial that I call Basic Batch.

Basic Batch


The first of the batch commands I am going to teach you are the '@echo off' and the 'Echo' commands

@echo off


This can be used in 2 cases, one use can be @echo off, this will tell the batch file not to show the command(s) it is running underneath the '@echo off' just the output (from them).
Then the @echo on command can be used this tell the batch file the opposite basically.

Example:
Code:

@echo off
Echo Hello world!
pause

(Too use this open a notpad file and paste the code into it, click save as, and put the filename as test.bat and then cahnge then change the file type to "all files")

Echo

You may have noticed the 'Echo' there, this indicates to show the user any text typed after echo.
You may have also noticed the pause, this indicates to wait until the user presses a key.

We could also add markers to that, markers work by setting ''checkpoint'' in the batch file which can then be used to jump back or fourth in the batch file.

Example:
Code:

@echo off
:loop
Echo Hello world!
Echo smash keyboard to continue....
pause > NUL
goto loop

The marker is set by typing :[any word here] and then using the 'goto' command to skip[ back to it.
Notice I also used a '> NUL' after the pause, this indicates for the batch file not to display the usual "press any key to continue..." message, instead it display's nothing, So I wrote my own message 'Echo smash keyboard to continue....'

That concludes this tutorial check out my other posts for any other tutorials on batch programming.

Kieron xD


Last edited by Admin on Mon May 18, 2009 7:31 pm; edited 1 time in total
avatar
Logic_Bomb
Admin
Admin

Posts : 161
Join date : 2009-05-12
Age : 25
Location : Cyberspace

View user profile http://the-underground.darkbb.com

Back to top Go down

Re: Basic Batch [TUT]

Post by Oliver on Mon May 18, 2009 7:12 pm

Nice tutorial for those who are just entering the ways of batch.
I look forward to Intermediate and Advanced ^^

REP+
-Oliver.

Oliver
Admin
Admin

Posts : 8
Join date : 2009-05-14
Age : 23

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum