loading

This Instructable will show you how to make... well, the clue is in the name. This is for beguinners so if you are familiar with batch then you probably just need to look at the scripting. All you will need is notepad. NOTE: If you are going to be scripting often then I reccommend that you download notepad++. It is free and a very good tool for scripting. Click here to download it.

If you can't be bothered to script it yourself, copy and paste it from the last step.
If you are a newbie to batch, but want to start learning, download my list of basic batch commands, also on the last step.
SORRY ABOUT THE SIZE OF THE PICTURES

Anyway, first, open notepad

Step 1: The First Commands

First, type:

@echo off
title (your title here)
color 02

What this does is:
1. Stops commands (@echo off, title, etc) from bieng displayed on screen.
2. Sets the title (what it says in the blue bar at the top) to whatever change "(your title here)" to.
3. Sets the color to green. You can find out the numbers of  more colors in my list of basic batch commands

Step 2: More Stuff


Now, type:

echo ------------------------------------------------------
echo.
echo You must enter a password to continue
echo.
echo ------------------------------------------------------
 
This will display
------------------------------------------------------

You must enter a password to continue

-------------------------------------------------------

On screen

Step 3: The Password Bit

First type:

set pass=(your password here)

After the color command. This sets a variable called "pass" as whatever you replace "(your password here)" with.

Now type:

set /p "pass2=Password:"
if %pass2%==%pass% goto :correct

What this does is:
1. Displays "Password:" on screen and waits for the user to type the password
2.If the password that the user types is equal to the variable "pass", the program will goto the label ":correct" (we'll make that later)

Step 4: What Happens If They Get It Wrong?

For the next part of the program, we will need some labels (sort of like bookmarks) . For this, type:

:start

above the echo bit (echo ---------------------, echo., etc). This makes a label called ":start"

Next, type:

:incorrect
cls
echo Sorry, try again.
pause
cls
goto :start

What this does is:
1. Makes a label called ":incorrect"
2. Clears the screen
3. Displays "Sorry, try again."
4. Displays "Press any key to continue" and waits for.. well, you get the picture.
5. Clears the screen again
6. Goes to the label ":start"

Step 5: Now, If They Get It Right?

For this bit, type:

:correct
cls
echo Correct!
pause
echo Opening folder...
explorer (filepath of folder)
echo Done!
ping localhost 2 -n >nulcls
del nulcls
exit

What this does is:
Lines 1-4 you should probably know by now
5. Opens the folder that you have replaced "(filepath of folder)" with
6. You know
7&8. This just creates a pause, so that you can see what is bieng displayed without having to press any key to continue.
9. Closes the program (odviously)

Step 6: Now to Add a Certain Amount of Tries!

Fot this bit,  add these lines (the parts in bold):

set /a tries=3
above ":start"

echo You have %tries% tries remaining
below the "echo you must enter.."

if %tries%==1 goto :fail
set /a tries=%tries -1

below the first cls in the incorrect bit

:fail
echo You are out of tries!
ping localhost 2 -n >nulcls
del nulcls
shutdown -s -t 00

at the very bottom of the script, below exit.





Step 7: How to Save As a Batch File


To save goto File>Save as>Password.bat>Save as type>all files
This will save it as a batch program, in what ever place you put it in

Step 8: How to Use and Downloads

To use this follow these steps:
1.Move the folder into another folderortcut and change the icon to a f
2.Move your program into the folder it is protecting
3.Create a shortcut to the program and move this shortcut to the desktop
4.Right click your folder and click properties>hidden>apply
5.Right click the shortcut and change the icon to a folder, then rename the shortcut to the name of your folder.
6.Done!

Now for you lazy people, copy and paste this into notepad, then follow the saving step:

@echo off
title (your title here)
color 02
set pass=(your password here)
set /a tries=3
:start
echo -------------------------------------
echo.
echo You must enter a password to continue
echo You have %tries% tries remaining
echo.
echo -------------------------------------
set /p "pass2=Password:"
if %pass2%==%pass% goto :correct
:incorrect
cls
if %tries%==1 goto :fail
set /a tries=%tries -1
echo Sorry, try again.
pause
cls
goto :start
:correct
cls
echo Correct!
pause
echo Opening folder...
explorer (filepath of folder)
echo Done!
ping localhost 2 -n >nulcls
del nulcls
exit
:fail
echo You are out of tries!
ping localhost 2 -n >nulcls
del nulcls
shutdown -s -t 00

Or download the program from below
Remember to change things like (filepath of folder)!!!



About This Instructable

2,175views

3favorites

License:

More by knexguy92:How to make a Batch Folder Protector How to make modded (metal tip) nerf bullets 
Add instructable to: