EASY BATCH FILE

About: I'm a 14 year old who enjoys programming and physics

This is how to make a simple batch file.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1:

OPEN NOTEPAD.

Step 2:

TYPE IN THE FOLLOWING:
@echo off
title MY PROGRAM
color a
echo WELCOME
echo.
echo 1.)START
echo 2.)EXIT
echo.
set /p var=YOUR CHOICE:
if %var%==1 goto HELLO
if %var%==2 exit
:HELLO
cls
echo PLEASE CHOOSE AN OPTION
echo.
echo 1.)OPEN GOOGLE
echo 2.)OPEN EMAIL
echo 3.)SHUTDOWN COMPUTER
echo 4.)EXIT
echo.
set /p var=YOUR CHOICE:
if %var%==1 start www.google.com
if %var%==2 start www.gmail.com
if %var%==3 shutdown -s
if %var%==4 exit
pause
exit

Step 3:

Save as program.bat

Be the First to Share

    Recommendations

    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    3 Discussions

    0
    None
    DylanM114

    Tip 1 year ago

    its also good practice to do this in order to prevent syntax errors like just pressing enter without entering anything or just pressing space and then enter. If you just press enter, "var" will be null and you cant compare a null variable to a string or a number. Now the file knows that its an empty string and will be able to compare the two and wont close the batch file.

    set /p "var=YOUR CHOICE:"

    and also do it with the if statements

    if "%var%"=="1" start www.google.com

    along with what everyone else said about putting an else statements or something underneath it to tell the user that they typed in an invalid entry

    0
    None
    UglyN

    2 years ago

    I'm not being rude, but you made 2 mistakes:

    1. You should put a else statement after choices

    2. Who needs to shutdown their computer through a batch file?

    This program works, but you may want to add an else statement after the choices. Currently if you enter a 3 in the first choice then it goes to :HELLO