Batch Files Tutorial - If Statement

July 31, 2009 - 10:11 pm

Jake “Master Jake” Chappell teaches you how to use the if statement when dealing with batch files.

Please comment and rate. If you like my video tutorials spread the word.

Website: http://masterjake.co.nr/
E-Mail: skateparkceasercash@yahoo.com

Duration : 0:5:20


[youtube Qr8L4x-qJ-Y]

25 Responses to “Batch Files Tutorial - If Statement”

  1. A7XRules4life Says:

    How do I make it …
    How do I make it say something if I enter the wrong variable? Like a password? How do I make it say like “That password is wrong” and can I make it have certain number of attempts? Like set it to 4 attempts and then it locks out?

  2. TACOS11211 Says:

    Hehe :D
    Hehe :D

  3. Scj0production Says:

    thanks man im going …
    thanks man im going to do one in the computer lap hehe :)

  4. TACOS11211 Says:

    Scj0production At …
    Scj0production At ur school the CMD is blocked… like you said. To unblock it go into notepad type

    @echo off
    command
    @echo on

    Then save it as a .bat file and open it. Should open CMD and not be blocked.
    BTW im not responsable if u get cought. :)

  5. Scj0production Says:

    I want to make one …
    I want to make one on the school computer how do i get passed command prompt its locked or restricted

  6. bcarl10101 Says:

    thanks!
    thanks!

  7. MasterJake777 Says:

    do it like this


    do it like this

    set /p blah=Enter Stuff:
    if “%blah%”==”What is up” (
    do some stuff
    )

    notice the quotes around the string with spaces and around the variable just because

  8. bcarl10101 Says:

    How can i make the …
    How can i make the user type in more than one word and have an if statement test it? Im making a batch file that says “Hello, how are you?” and I have to type in “Good, how are you? or “Not so good, how are you?” how would i make an if statement test if i typed in these two phrases? it doesn’t seem to work with multiple word but works with one word like in ur vid.
    thanks!

  9. MasterJake777 Says:

    by not putting the …
    by not putting the pause statement lol

  10. 1blue1 Says:

    how ? xD
    how ? xD

  11. MasterJake777 Says:

    yes if you want
    yes if you want

  12. 1blue1 Says:

    can i make it just …
    can i make it just exit without pause when i type anything else than Y and y ?

  13. MasterJake777 Says:

    no problem ;]
    no problem ;]

  14. bcarl10101 Says:

    nice dude i forgot …
    nice dude i forgot how to do if statements and this way worked. thanks (oh ya i rated 5 stars)

  15. MasterJake777 Says:

    your welcome xD
    your welcome xD

  16. stinkee2 Says:

    thank you :) and im …
    thank you :) and im gonna go search now for that music hehehe

  17. MasterJake777 Says:

    i got it off …
    i got it off limewire lol just searched “gta san andreas theme music” or something.

    @echo off
    set command=Command (enter y):
    if /i %command%==y (
    start program.exe <- whatever program
    copy files location <- files and location
    )

    something like that

  18. stinkee2 Says:

    how would I go …
    how would I go about doing something like this:
    if (y is pressed)(run program at a location)
    and also:
    if (y is pressed)(copy files to a location)

    and Im going to start making videos soon just for fun and where could I find that intro music that you used… its great :)

  19. MasterJake777 Says:

    you need quotes …
    you need quotes around it if theres spaces

  20. Goldy3418 Says:

    it doesn’t work …
    it doesn’t work with more than one word in the if statement, like if %talk%==not good it doesn’t do want i set it to do

  21. xedon2 Says:

    ah ok, thnx
    ah ok, thnx

  22. MasterJake777 Says:

    because your …
    because your echoing Yes/No not actually letting them type something. Change that line to:

    set /p name=Yes/No

    try that

  23. xedon2 Says:

    why doesnt this …
    why doesnt this work?

    @echo off
    color F
    :namewrong
    set /p name=Name:
    Echo So your name is %name%?, type yes or no to confirm.
    Echo Yes/No
    pause
    if %name%==yes goto nameright
    if %name%==no goto namewrong
    :nameright
    pause

  24. Zemoraxis Says:

    no… if you …
    no… if you compile the batch and make a batch trojan… then infiltrate the system and implant the batch virus in the start up…. it is no longer a noobs virus.
    If your going to call it ‘ineffective’… learn about batchs to its fullest before you comment about it being ‘noobish’.

  25. vidfun101 Says:

    lol
    lol

Leave a Reply