Instructables
Picture of 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!
 
Remove these adsRemove these ads by Signing Up

Step 1: What You Need To Know

Picture of 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.
Jbabu31204 months ago

What is the password?

ghandimanning10 months ago
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
)
felix451 year ago
what theam is that
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.
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.
lukeford1 year ago
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
greyadam255 years ago
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
RedFlash5 years ago
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
will4215 years ago
Or you can just place it in the startup folder.
Arbitror5 years ago
Could you post that theme?
Necrohero (author)  Arbitror5 years ago
the one on my background desktop?
The Windows theme.
Necrohero (author)  Arbitror5 years ago
O sure. No issue. Thats my next instructable!
lemonie5 years ago
Well written. Do you get this to start in full-screen mode? (if you do add-in how) L
Necrohero (author)  lemonie5 years ago
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!
Yes I know how, I was asking whether you did this - should add it in (if you haven't) L
Necrohero (author)  lemonie5 years ago
o, yea i did it, and ok, I'll add it in soon! thanx!
It needs this to work to the best effect, (windowed it can be ignored or closed) L
how did you change your start menu?
Necrohero (author)  Psychic Master5 years ago
Lol, i will be posting how to change the Theme next, so sit tight! .
PKM5 years ago
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.
Necrohero (author)  PKM5 years ago
Thank You! Again, not very practical, but useful for the lesser versed computer person. I will try better on my next one!