|
Project Exertus
|
 |
« Reply #3 on: November 08, 2008, 05:22:09 pm » |
|
Not bad for a first try.
Code for lazy people:
@echo off title CrnJacKer's Batch Tutorial V1 :hp cls Echo Welcome to CrnJacKer's Batch Tutorial V1. Echo. Echo Check www.havenworld.co.uk for more releases and batch information Echo. Echo ......................................................................... Echo. Echo Choose which thing you want to learn: Echo. Echo getting started Echo. Echo how to title your batch file Echo. Echo how to add text to your batch file Echo. Echo how to make a space or skip a line in a batch file Echo. Echo what is @echo off? Echo. Echo how to add options/to choose between options Echo. Echo how to add "loops" or non-stop text Echo. Set /p tut=Which tutorial? (DO NOT LEAVE A SPACE BETWEEN EACH WORD).
If %tut%==gettingstarted goto gs If %tut%==howtotitleyourbatchfile goto title If %tut%==howtoaddtexttoyourbatchfile goto text If %tut%==howtomakeaspaceorskipalineinabatchfile goto space If %tut%==whatis@echooff? goto echo If %tut%==howtoaddoptions/tochoosebetweenoptions goto options If %tut%==howtoadd"loops"ornon-stoptext goto loop
:title cls Echo To add a title to your batch file, you should only type this simple word, Echo then your title. Echo. Echo title YOUR TITLE Echo. Echo For example: title CrnJacKer's Batch tutorial V1 Echo. Echo The title will display on the top toolbar, or bar. Echo. Echo Recommended to be added after you have typed the @echo off line. Echo. Set /p continue=Do you wish to know anything else? (y/n)
If %continue%==y goto :hp If %continue%==n goto close
:text cls Echo This is really simple, all you have to do is type Echo THEN YOUR TEXT HERE Echo. Echo For example: Echo. Echo Echo Welcome to CrnJacKer's Batch tutorial V1 Echo. Set /p continue=Do you wish to know anything else? (y/n)
If %continue%==y goto :hp If %continue%==n goto close
:space cls Echo This is also simple, just type Echo. Echo. Echo For example: Echo. Echo Echo Welcome! Echo Echo. Echo Echo To my tutorial! Echo. Echo So it basically leaves a space, the Echo or "." will not show in the batch file. Echo Therefore it leave a blank space. Echo Like for example: Echo. Echo ................................... Echo ................................... Echo. Echo The above was WITHOUT Echo. Or a space, the below shown will be with Echo Echo. Echo. Echo ............................... Echo. Echo ............................... Echo. Echo I hope you understood from this, and learnt as well. Echo.
Set /p continue=Do you wish to know anything else? (y/n)
If %continue%==y goto :hp If %continue%==n goto close
:echo cls Echo @echo off IS THE FIRST THING you type when you start making a batch file, Echo especially from scratch. Echo. Echo You will find all professional batch files with a start @echo off. Echo. Echo What it does is hides the directory, or where it goes to run your batch Echo file itself, which of course, makes it WAY MORE NEATER. Echo. Echo It pretty much is hard to explain, but you may try it and see for yourself by Echo Right click on this batch file from where you downloaded it to on your computer, Echo and click "Edit". Echo. Echo You will see @echo off at the beginning, remove it, then save, then try it. Echo. Echo Then you will know the difference, thanks for reading, make sure to re-add it Echo if you want to. Echo. Set /p continue=Do you wish to know anything else? (y/n)
If %continue%==y goto :hp If %continue%==n goto close
:options cls Echo This might be not easy, so make sure to concentrate. Echo. Echo To make an option, for you or anyone to input what he chooses, you type in Echo your batch file: Echo. Echo Set /p option=Choose Echo. Echo Remember that you can always edit it, so it can be Set /p me=fksaflsafd Echo You should do it like this. Echo. Echo Echo favorite food? Echo Echo Burger Echo Echo Pizza Echo Echo lol Echo Set /p favorite=Which? Echo. Echo Then, there is the "If" method that you need to add, after the Echo Set /p favorite=Which? Option. Echo. Echo If (percent sign)favorite(percent sign)==Burger goto burger Echo If (percent sign)favorite(percent sign)==Pizza goto pizza Echo If (percent sign)favorite(percent sign)==lol goto lol Echo. Echo So then, until now, here is the full code: Echo @echo off Echo title test Echo :homepage Echo Echo favorite food? Echo Echo Burger Echo Echo Pizza Echo Echo lol Echo Set /p favorite=Which? Echo If (percent sign)favorite(percent sign)==Burger goto burger Echo If (percent sign)favorite(percent sign)==Pizza goto pizza Echo If (percent sign)favorite(percent sign)==lol goto lol Echo. Echo We are almost done with the tutorial, now to add the options itself. Echo. Echo You see, it says "Burger goto burger", here's where the "goto burger" comes in. Echo Goto burger, means it goes to burger, which follows all the codes written under Echo So you add an equal sign ":" than "burger" in a new line, then type Echo anything under it, such as Echo, or set option, etc. Stay tuned Echo for V2 for more information, and updated.
Echo. Set /p continue=Do you wish to know anything else? (y/n)
If %continue%==y goto :hp If %continue%==n goto close
:loop cls Echo This is simple, but NOT RECOMMENDED. Echo. Echo What this does is repeat the same text you have inputed forever, Echo for unlimited amount of time Echo. Echo To do this: Echo. Echo :loop Echo YOUR TEXT Echo goto loop Echo. Echo Then it will keep saying the same thing, forever.
Echo. Set /p continue=Do you wish to know anything else? (y/n)
If %continue%==y goto :hp If %continue%==n goto close
:gs cls Echo Hello, welcome to batch, batch is a cmd file that helps you in many things. Echo It is a batch that can be used to operate and do things for your computer, Echo Such as copy, renaming, running, finding, and many other things. Echo In this tutorial, you will LEARN how to make your own batch file, Echo out of scratch, there will be 3 versions of this tutorial, all released first Echo at www.havenworld.co.uk , don't forget to register there! Echo. Echo First, we will start this from scratch, open Notepad. Echo Then, type @echo off Echo After that, title YOUR TITLE HERE. Echo After that, type Echo Hello World, or anything else. Echo Then click "File" then click "Save as" Echo then click "Text Document" and change it to "All files" Echo Then type (QUOTATIONS INCLUDED) "yourbatchfilenamehere.bat" Echo Then run! Echo. Echo Also, you may follow these tutorials to get you a head start. Echo. Set /p contine=Do you want to start learning by reading tutorials now? (yes/no)
If %contine%==yes goto :hp If %contine%==no goto far
:far cls
:close cls Echo Thanks for using this, remember you can always check for V2 at: Echo www.havenworld.co.uk Echo V2 will contain: Echo - Different text and background color! Echo - Easier navigation way to choose between more tutorials. Echo - MANY additions to new tutorials, such as: Echo 1 How to change your text and background color. Echo 2 How to copy things to folders, using batch commands AKA Xcopy. Echo 3 How to make an option start at a new page. Echo AND MORE Echo - Old tutorials will be updated. Echo - The-all-new method to add batch examples directly to your desktop using V2 Echo - You may make batch files on the way to this. STAY TUNED pause
|