[TUTORIAL] Batch Files menu

User Tag List

Results 1 to 5 of 5
  1. #1
    insignia96's Avatar Banned
    Reputation
    33
    Join Date
    Oct 2008
    Posts
    304
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [TUTORIAL] Batch Files

    Making Batch Files


    Introduction:

    First off when making a batch file the first line should always be:
    Code:
     @ECHO OFF
    This is important.

    To save a file as a batch file open notepad or any other text editor, write the first line @echo off then go Save As.., All Files, then save it as NAME.bat

    Now it is a batch file.




    Your First Batch File:

    Now that you have saved your file as a .bat and written your @ECHO OFF, try to run it. You should see that it flashes a quick blank Command Prompt then it disappears. This is Because there is no content. Lets add a simple Hello World!
    Add this to the second line of your batch file.
    Code:
    echo Hello World!
    Now try to run it again. You should see the same quickly disappearing box but it should say "Hello World!" in it. Now your probably wondering how to make it stay. Well to make it stay you have to add a pause.
    Add this to the third line:
    Code:
    PAUSE
    Now your batch file should write this
    Code:
    Hello World!
    Press any key to continue...
    Congratulations you have now written your first batch file!


    A Second, More Complicated Batch File

    Now we will write a batch file with a menu.

    First write the @echo off line the write
    Code:
    :MENU
    cls
    echo Welcome to my menu!
    echo Please select an an option
    echo 1 = OPTION1
    echo 2 = OPTION2
    set choose = 1
    set /p choose =Please type your choice:
    IF you ran this you would see the menu but when you chose something it would close to fix this we need to add some goto's and code for the options.

    First lets add the goto's under the last line of the previous code add this:
    Code:
    if %choose% == 1 GOTO OPTION1
    if %choose% == 2 GOTO OPTION2
    Now let's add some code for each option here is a simple code for each option:
    Code:
    :OPTION1
    cls
    echo This is Option 1
    pause
    GOTO MENU
    
    :OPTION2
    cls
    echo This is Option 2
    pause
    GOTO MENU
    Now you have a simple menu.

    Commands:

    COMMANDS USED:

    CLS | This clears the screen of any previously written text
    ECHO | This writes the text after it
    SET and SET /p | These are used to make menus. SET sets the value of a variable and SET /p lets you make it say CHOOSE AN OPTION:_ and so forth.
    GOTO | This lets you go to a specific chunk of code.
    PAUSE | Pauses the flow of code until any key is pressed.
    IF | It is an if command okay do i really need to explain it?
    :SOMENAME | This is used to name a chunk of code and should always have a cls as the first line. (IMHO at least)

    Notes:

    Batch file commands are the same as in a command prompt.

    Batch files are very fun for pranks or fake viruses. I may add the fake shutdown virus on here later.

    Batch files can be a very useful tool.


    Enjoy!


    [TUTORIAL] Batch Files
  2. #2
    maclone's Avatar / Authenticator enabled
    Reputation
    2420
    Join Date
    Nov 2007
    Posts
    8,726
    Thanks G/R
    0/1029
    Trade Feedback
    0 (0%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by insignia96 View Post
    First off when making a batch file the first line should always be:
    Dude...
    black on gray??

    C'mon, change that font.
    Zomfg. And no, don't ask. - Dombo did it.

  3. #3
    insignia96's Avatar Banned
    Reputation
    33
    Join Date
    Oct 2008
    Posts
    304
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it looks fine.

  4. #4
    Edge94's Avatar Contributor
    Reputation
    148
    Join Date
    Aug 2008
    Posts
    466
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it does look fine, i can read it perfectly.... and nice tut

  5. #5
    insignia96's Avatar Banned
    Reputation
    33
    Join Date
    Oct 2008
    Posts
    304
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks

    (fillah)

Similar Threads

  1. Help with executing custom item batch file to heidi sql?
    By Drelanarus in forum World of Warcraft Emulator Servers
    Replies: 10
    Last Post: 04-27-2008, 11:47 AM
  2. Navicat 8 Executing Batch Files
    By Ltleontis54321 in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 03-30-2008, 12:50 PM
  3. How to change entry id's with batch file?
    By Maisteri in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 03-06-2008, 01:19 PM
  4. I Get This Error When I Run Execute Batch File On Navicat
    By BillyBob31 in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 03-01-2008, 07:28 AM
All times are GMT -5. The time now is 06:32 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search