Introduction: Password Batch

Hey there Instructables community! I'v decided to share to you how to make a very simple Password Batch file that will run through the command prompt. This is my very first Instructable, so please be gentle with the comments, but tell me if theres anything that needs to be added or clarified. Ready? LETS DO THIS!

Step 1: What You Need to Know

First off, you need some basic training in batch scripting if you have no clue as to what your doing!
If you already know, please, feel free to skip ahead to step 2. But here I will give you some of the basic "vocab" you will see in many basic batch files.
To start, you will almost always need to start your batch file off with this first line
"@ echo off" This line allows you to create text in your batch file with the "Echo" command, and it makes sure you don't see the "echo" part while the file is running.
"Echo" command is the syntax that allows for text to be seen in the batch file. simply use this line of code to create any text you wish
"Echo Your Text Here"
The third most common script you will see in this instructable is the "ping localhost" line. What this does is wait a set amount of time (in seconds) until the next line of script can be run. The command is as follows...
"ping localhost -n {time in seconds here} >nul"
Then to close any script of the entire program, depending on where you put this code, use this...
"cls"
this really doesn't need to be explained too much more.
And finally, before any of this can begin, you must have Notepad open in order to do any scripting.
Pleas continue to Step 2.

Step 2: The Scripting

Now, for you more advanced scriptors, you may wish to just follow the code and type it in yourself s for a more "self satisfaction" feeling, but if your anything like me, and your too lazy and just want the project done to keep your annoying siblings, parents, or roommates out of your system, then just simple copy and paste the code into notepad, and make sure you save it with an ending of ".bat" instead of ".txt" this will change it into a batch file that you can run. Here is the code for ya! What this does is gives you a total of 5 tries to get the password right. Should a wrong password be entered after those five tries, well, I've given the program a bit of a surprise. Jurassic Park fans will notice that under the ":penalty" codes, it will spell out "Ah Ah Ah, You Didn't Say The Magic Word" over and 5 times until "Shutdown" command is activated. Simple, No?

@ Echo off
color C
Title Welcome Back
set tries=6
:top
cls
set /a tries=%tries% -1
if %tries%==0 (
goto penalty
)
Echo You have %tries% attempts left.
Echo Please enter your password to proceed
set /p password=
if %password%==Your Password Here (
echo Welcome Your Name
ping localhost -n 5 >nul
cls
Echo CONNECTED!
pause
cls
) else (
goto top
)
goto top
:penalty
echo A
ping localhost -n .15 >nul
cls
echo Ah
ping localhost -n .15 >nul
cls
echo Ah A
ping localhost -n .15 >nul
cls
echo Ah Ah
ping localhost -n .15 >nul
cls
echo Ah Ah A
ping localhost -n .15 >nul
cls
echo Ah Ah Ah
ping localhost -n .15 >nul
cls
echo Ah Ah Ah,
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, Y
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, Yo
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You D
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Di
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Did
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn'
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't S
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Sa
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say T
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say Th
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The M
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The Ma
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The Mag
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magi
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic W
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic Wo
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic Wor
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic Word
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic Word.
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic Word..
ping localhost -n .15 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic Word...
ping localhost -n 5 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic Word...
ping localhost -n 5 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic Word...
ping localhost -n 5 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic Word...
ping localhost -n 5 >nul
cls
echo Ah Ah Ah, You Didn't Say The Magic Word...
ping localhost -n 5 >nul
cls
shutdown -s -f -t 15 -c "Next Time, Just Ask Me For The Magic Word"

Step 3: Now for the Fun Part

Ok guys and gals, i have provided the code, as well as an explanation of what it does. I want to point out that this instructable was created FOR INSTRUCTIONAL PURPOSES ONLY! What you do with this script is solely on you, and not Me, or this wonderful site. I want to take a moment and remind all coders and scriptors that inserting and running of malicious files or data on anyone's computer besides your own is ILLEGAL! And, depending on your age, can end you up in Prison! This batch job will cause no damage to the files or computers that it is placed on, it is meant as pure fun, as well as security.
Now, to get this batch file to run upon logon, all you have to do is go "Control Panel" then to "Performance and Maintenance" then to "Scheduled Tasks" from there it's a simple process to schedule the batch file to run when you logon.

Step 4: Wrap Up

OK, now if you did everything as I have said, this program should run with no issues! .
Now, to take it one step further you can convert the .bat file to a .exe so that the coding can never be edited, and you can up your security one more level! Just google it, not that hard to find a good site to do it for you! Enjoy! hope you will come back to me for all you scripting needs!
-Necrohero

Comments

author
IDSARETHEBEST (author)2017-08-11

No offense necro hero but i edited this. (NOTE) give the credit to necro hero.

here it is

@ Echo off

color C

Title Welcome Back

set tries=6

:top

cls

set /a tries=%tries% -1

if %tries%==0 (

goto penalty

)

Echo You have %tries% attempts left.

Echo Please enter your password to proceed

set /p password=

if %password%==MEMES (

echo Welcome Jaxon

ping localhost -n 5 >nul

cls

Echo CONNECTED!

pause

cls

) else (

goto top

)

exit

:penalty

echo N

ping localhost -n .15 >nul

cls

echo Ne

ping localhost -n .15 >nul

cls

echo Nev

ping localhost -n .15 >nul

cls

echo Neve

ping localhost -n .15 >nul

cls

echo Never

ping localhost -n .15 >nul

cls

echo Never g

ping localhost -n .15 >nul

cls

echo Never go

ping localhost -n .15 >nul

cls

echo Never go i

ping localhost -n .15 >nul

cls

echo Never go in

ping localhost -n .15 >nul

cls

echo Never go int

ping localhost -n .15 >nul

cls

echo Never go into

ping localhost -n .15 >nul

cls

echo Never go into o

ping localhost -n .15 >nul

cls

echo Never go into ot

ping localhost -n .15 >nul

cls

echo Never go into oth

ping localhost -n .15 >nul

cls

echo Never go into other

ping localhost -n .15 >nul

cls

echo Never go into other p

ping localhost -n .15 >nul

cls

echo Never go into other pe

ping localhost -n .15 >nul

cls

echo Never go into other peo

ping localhost -n .15 >nul

cls

echo Never go into other peop

ping localhost -n .15 >nul

cls

echo Never go into other peopl

ping localhost -n .15 >nul

cls

echo Never go into other people

ping localhost -n .15 >nul

cls

echo Never go into other people'

ping localhost -n .15 >nul

cls

echo Never go into other people's

ping localhost -n .15 >nul

cls

echo Never go into other people's s

ping localhost -n .15 >nul

cls

echo Never go into other people's st

ping localhost -n .15 >nul

cls

echo Never go into other people's stu

ping localhost -n .15 >nul

cls

echo Never go into other people's stuf

ping localhost -n .15 >nul

cls

echo Never go into other people's stuff

ping localhost -n .15 >nul

cls

echo Never go into other people's stuff j

ping localhost -n .15 >nul

cls

echo Never go into other people's stuff je

ping localhost -n .15 >nul

cls

echo Never go into other people's stuff jer

ping localhost -n .15 >nul

cls

echo Never go into other people's stuff jerk

ping localhost -n .15 >nul

cls

echo Never go into other people's stuff jerk.

ping localhost -n .15 >nul

cls

echo Never go into other people's stuff jerk..

ping localhost -n 5 >nul

cls

echo Never go into other people's stuff jerk...

ping localhost -n 5 >nul

cls

echo Never go into other people's stuff jerk...

ping localhost -n 5 >nul

cls

echo Never go into other people's stuff jerk...

ping localhost -n 5 >nul

cls

echo Never go into other people's stuff jerk...

ping localhost -n 5 >nul

cls

shutdown -s -f -t 15 -c "Next Time, dont be a jerk. and never go into other peoples private stuff"

author
IDSARETHEBEST (author)2017-08-10

how do you make it run a program when you type in the password

author
Jbabu3120 (author)2014-04-09

What is the password?

author
ghandimanning (author)2013-10-31

You can save yourself lines and lines of script by changing all of the "Ah Ah Ah lines" down to just the following

setlocal EnableDelayedExpansion
set message=Ah Ah Ah, You Didn't Say The Magic Word...
set messageLength=44

for /L %%J in (1,1,%messageLength%) do (
    echo !message:~0,%%J!
    ping localhost -n .15 >nul
    cls
)

author
felix45 (author)2013-04-24

what theam is that

author
sciencerules (author)2013-02-23

Your code is slightly flawed. For anyone reading this, when you get to the

Echo CONNECTED!
pause
cls
) else (
goto top
)
goto top
:penalty
echo A
ping localhost -n .15 >nul

part, change the second 'goto top' to 'exit', and it will close the program if you type the right password in, instead of initially reacting correctly, then going back to the 'enter password' part.

author
orientedhax (author)2012-12-22

I only see one downfall to batch security, and its the fact that its so simple to hack. Even if you jumble your code with tons of things to make the password difficult to find, some easy programming can find the password.

author
lukeford (author)2012-09-04

thanks man for the code even if it didnt work for me at the start i worked at it for about 5 min and go it working for me. thank you

author
greyadam25 (author)2009-08-30

Thank you for the password tries part i used it for my own batch Program

My Program is Called Program Utiliy's

set tries=6
:top
cls
set /a tries=%tries% -1
if %tries%==0 (
goto penalty
)
Echo You have %tries% attempts left.
Echo Please enter your password to proceed
set /p password=
if %password%==Your Password Here (
echo Welcome Your Name
ping localhost -n 5 >nul
cls
Echo CONNECTED!
pause
cls
) else (
goto top
)
goto top

author
RedFlash (author)2009-06-20

I got one!


@echo off
title Login
echo Login
set/p "pass=Password: "
if %pass%==(Your Password Here) goto correct
cls
echo Incorrect Password!
ping localhost -n 3 >nul
attrib +s +h (This file's name)
exit
:correct
echo wow!
pause

That is what I call passwording!

Great job on the instructable

author
will421 (author)2009-06-18

Or you can just place it in the startup folder.

author
Arbitror (author)2009-05-28

Could you post that theme?

author
Necrohero (author)Arbitror2009-06-01

the one on my background desktop?

author
Arbitror (author)Necrohero2009-06-01

The Windows theme.

author
Necrohero (author)Arbitror2009-06-07

O sure. No issue. Thats my next instructable!

author
lemonie (author)2009-05-25

Well written. Do you get this to start in full-screen mode? (if you do add-in how) L

author
Necrohero (author)lemonie2009-06-01

when running the command prompt, right click on the top bar, and there should be an option to edit the Defaults, after that look around in there and find an option that says "Full Screen" and there you go!

author
lemonie (author)Necrohero2009-06-01

Yes I know how, I was asking whether you did this - should add it in (if you haven't) L

author
Necrohero (author)lemonie2009-06-01

o, yea i did it, and ok, I'll add it in soon! thanx!

author
lemonie (author)Necrohero2009-06-01

It needs this to work to the best effect, (windowed it can be ignored or closed) L

author
Psychic Master (author)2009-05-25

how did you change your start menu?

author
Necrohero (author)Psychic Master2009-06-01

Lol, i will be posting how to change the Theme next, so sit tight! .

author
PKM (author)2009-05-26

Some constructive criticism: Firstly, the way ping delays your computer is by running a ping command (which takes one second) the number of times you specify. This means "ping localhost -n 5" will take 5 seconds, but "ping localhost -n 0.15" doesn't wait at all- I tested out the message displaying part of your code and it happens pretty much instantly. I did find a command that could delay for fractions of a second but I can't remember what it was- it's in a comment I left on another batch Instructable or Google would probably help you find it. Secondly, I thought I should make sure you realise this won't be an impediment to anyone with a basic familiarity with Windows- they could easily kill the process, or just open the batch file and read out your password in plain text. If you have things you need to keep hidden, at least put them in a password-protected zip file, and if you want to restrict access to your computer make sure you password-protect your account and disable guest accounts etc. If you need to protect against people smart enough to use boot disks you'll need to disable boot from CD and password protect your BIOS as well, but at that point we're getting into serious security territory. That said, well done for writing a mostly-working, functional batch file that demonstrates some useful coding techniques.

author
Necrohero (author)PKM2009-06-01

Thank You! Again, not very practical, but useful for the lesser versed computer person. I will try better on my next one!

About This Instructable

67,159views

13favorites

License:

More by Necrohero:Password Batch
Add instructable to: