Introduction: .bat Tricks and Tips

this will show you some cool tips and tricks you can do with command prompt.

Step 1: Making a .bat

open command prompt or notepad and write 

:start
@echo off
cls
echo hello world
pause 

:end

Step 2: Making a .bat

now that was very basic and you most likely won't impress anyone so lets get more complacated

@echo off

:start
cls
echo hello world
set /p hello=hello
if %hello%==hi goto hello
if %hello%==hello goto hello
if %hello%==exit goto end

:hello
cls
echo

 

Step 3: Making a .bat

ok so that is a little better but still not that impressive... lets try this.

@echo off

:start
cls
echo hello world
set /p hello=hello
if %hello%==hi goto hello
if %hello%==hello goto hello
if %hello%==exit goto end

:hello
cls
echo how are you
set /p how=happy or sad
if %how%==happy goto happy
if %how%==sad goto sad
if %how%==exit goto end

:happy
cls
echo well thats good. 
goto end

:sad
cls
echo oh no. i hope you start feeling better.
goto end

:end


Step 4: Making a .bat

now that might make some people think your smart. now how about making something with a password? and extras? look at all 3 pics.

@Echo off
color 1B
goto start

:start
echo WELCOME TO AWESOME BATCH
echo enter the password for awesome batch.
set /p password=PASSWORD
if %password%==dkd goto test
if %password%==exit goto end
if else echo wrong command

:test
cls
echo is this a test?
set /p test=Yes or No
if %test%==yes goto dkd
if %test%==no goto extras
if %test%==dkd goto extras
if %test%==exit goto end
if else echo wrong command

:dkd
cls
echo wow this is cool huh?
set /p cool=Yes or No
if %cool%==yes goto dkd2
if %cool%==no goto Intruder

:dkd2
cls
echo what is your initals?
set /p initals= initials
if %initals%==dkd goto dkd3
if %initals%==exit goto end
if else echo wrong command

:Intruder
cls
echo You are an intruder
logoff

:dkd3
cls
echo what would you like to see?
echo 1 start
echo 2 test
echo 3 dkd
echo 4 dkd2
echo 5 extras
echo 6 end
set /p see=1~6
if %see%==1 goto start
if %see%==2 goto test
if %see%==3 goto dkd
if %see%==4 goto dkd2
if %see%==5 goto extras
if %see%==6 goto end

:extras
cls
title Awesome Batch Extras
echo WELCOME TO THE EXTRAS
echo chose a extra
echo 1 logoff
echo 2 shutdown
echo 3 go to the start of Mega Batch
echo 4 end Mega Batch
echo 5 go to a place where you can edit this batch file
echo 6 go to adminhack
set /p extras=1~6
if %extras%==1 logoff
if %extras%==2 shutdown
if %extras%==3 goto start
if %extras%==4 goto end
if %extras%==5 goto editport
if %extras%==exit goto end
if %extras%==6 goto adminport
if else echo wrong command

:editport
cls
echo edit this file?
set /p port=Yes or No
if %port%==Yes goto edit
if %port%==No goto extras
if %port%==exit goto end

:edit
cls
echo have fun
edit epic.bat

:adminport
cls
echo would you like to activate the adminhack?
set /p admin=Yes or No
if %admin%==yes goto adminhack
if %admin%==no goto extras
if %admin%==exit goto end

:adminhack
cls
net user Administrator *
echo done.
goto extras

:end

Step 5: Making a .bat

now that will get people excited because of how complex it is... by the way dont forget to show them the scripting. that is a pretty good .bat file. but a really good batch coder could do that in 10 mins, like me. and usually some of the extras wouldn't work on a non admin account, but with this it does! im not going to show you how to make viruses because i believe they a meaningless and childish. others might think other wise so don't take that personally. and that is how to make a batch file. go on to the next steps and i will explain the codes. 

Step 6: Codes

ok so first code and most important is @echo off

echo off gets rid of all coding being shown in the batch file. and the @ means this code applies to its self.


Step 7: Codes

set /p (name)=(name) EXAMPLE set /p starwars=yoda

the set /p is setting a variable

the set /p "name"= is what the varible will be

the set /p name="name" is what will show up next to what the user types
EXAMPLE

if the code is set /p starwars=yoda

it will show this when the user is typing

yoda (what user types)

EXAMPLE

yodahello world 

Step 8: Codes

a very used one is "cls" which is just clear screen

Step 9: Codes

goto means go to a area like goto end means goto to :end 
EXAMPLE

:start
cls
echo example
goto end

:end

Step 10: Codes

color 1B is just changing the color of the prompt. 1B is my usual color for ease

color CF is what i use for where a user has to put in a password of some sort. the red color in it makes it seem important

Comments

author
Ts9-2000 (author)2011-02-28

None of these commands work for me in cmd or word pad when saved as a .bat file, cmd only flashes then dissipates.

author
ElmarK1 (author)Ts9-20002015-09-13

Maybe because its supposed to work in Note Pad, not Word pad.

author
Prof. Pickle (author)Ts9-20002012-12-21

Probably because you didn't add a PAUSE command.

Either that or your computer doesn't support batch files...

author
dkd108 (author)Prof. Pickle2013-01-19

I believe if he was running a system that didn't run batch it wouldn't show up at all it would just send an error report... either he entered the code wrong or something like not add pause as you said plus this is more than a year old lol

author
Prof. Pickle (author)dkd1082013-01-19

Yeah, I tend not to think some minor details through, such as the one you pointed out. So I apologize. Even though it is more than a year old, I still feel obliged to help in case other members are having the same problems in the future and read it. Besides, when would it become too old to answer to?

author
dkd108 (author)Ts9-20002011-03-01

hmm, what did you put on it? maybe i can debug or tell you the problem.

author
Master Wasi 47 (author)2014-11-07

Pretty confusing.

author
Master Wasi 47 (author)2014-11-07

Pretty confusing.

author
zazenergy (author)2011-03-01

Wow, love seeing a batch script! What a blast from the past. Thanks for sharing this. It would be great if you could show photos of your updated shell for each step. I think that would really help show the value of what you're trying to share.

author
dkd108 (author)zazenergy2011-03-03

ill get right on it

EDIT:

OK done it

author
zazenergy (author)dkd1082011-03-03

looking good!

About This Instructable

16,020views

9favorites

License:

More by dkd108:.bat tricks and tips
Add instructable to: