Comedy Hometown - Watch Comedy Hometown's Latest Video!

Welcome to Havenworld's Gaming, Computing and Programming Forums!

Unlock extra board access and remove this notice by registering for free below:
Choose username: Email:
Choose password: Antibot:
Type the letters shown in the picture to the left:
Verify password:

Pages: [1]   Go Down
  Print  
Author Topic: My first Batch file! - A tutorial for Batch file beginners to get started.  (Read 1959 times)
CrnJacKer
Havenworld Guru
***

Reputation: 20
Offline Offline

Posts: 848


Im a Proud Egyptian.


« on: November 08, 2008, 03:53:04 pm »


Well yeah, I know it's pretty much junk, and sucks  :'(

But I spent A LOT OF TIME on it, a week to fix one error, and how to complete it, hopefully it will take less time to make V2, which will be a big hit, then V3 (final release).

I will make lots of other batch files as well, since well, It's pretty nice, thanks to Matrix's guide I started using it, although there was when the error came, but I managed to fix it.

I take full credit for making it (this is from scratch), and Matrix probably, for making me start batch :)


http://www.mediafire.com/?x12vlnsj8zd



-CrnJacKer
rubenX2
Budding Havenworlder
**

Reputation: 0
Offline Offline

Posts: 12


« Reply #1 on: November 08, 2008, 04:17:36 pm »

So its a .bat file that teaches you how to create batch files?
Project Evolution
Elitist Jerk of SMF
Ex-Staff
Havenworld Inhabitant
****

Reputation: 13
Offline Offline

Posts: 618


WWW
« Reply #2 on: November 08, 2008, 04:17:57 pm »

Neat, what was the error?
Project Exertus
Elite Gold Member
*****

Reputation: 53
Offline Offline

Posts: 340

rawr!


« Reply #3 on: November 08, 2008, 05:22:09 pm »

Not bad for a first try.

Code for lazy people:
Code: [Select]
@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
iPl0xOr
Gold Member
****

Reputation: 3
Offline Offline

Posts: 162



« Reply #4 on: November 08, 2008, 10:43:48 pm »

That's better, we don't have to download it now. ;)
Proxima
Havenworld Guru
***

Reputation: 10
Offline Offline

Posts: 986


« Reply #5 on: November 09, 2008, 05:24:01 pm »

That's better, we don't have to download it now. ;)
Great!  ;D
MP
Tom > me. =)
Community Member
Elite Gold Member
*****

Reputation: 6
Offline Offline

Posts: 499


meow


WWW
« Reply #6 on: November 10, 2008, 02:55:44 am »

nice =] not that bad at all. What you got in mind for V2?
CrnJacKer
Havenworld Guru
***

Reputation: 20
Offline Offline

Posts: 848


Im a Proud Egyptian.


« Reply #7 on: November 10, 2008, 05:33:38 pm »

nice =] not that bad at all. What you got in mind for V2?

Thanks for the inspiring tip, I'm not sure yet, but I think I'm gonna barely work on V2, I already know how to make command makers/generators, and save it to a desktop (thanks to you, I couldn't find the guides off the internet, so I had to use your command generator, and learn the codes NOT C & P, I will make and release soon.







-CrnJacKer
Pages: [1]   Go Up
  Print  
 
 

Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC | Havenworld © 2006 - 2009 Havenworld Plc | The Peoples World
Page created in 0.154 seconds.