Madman123456
12-26-2009, 12:12 AM
Hey! Have you ever wanted to protect a folder with files in it with a password, but have had to dowload programs to do so? I figured this out a few days ago and decided to share it with all of you!
First off, make a folder named "Locker" and place whatever files you want to protect in this folder.
Next, open a notepad and enter the following code inside.
cls
@ECHO OFF
title Folder Locker
if EXIST "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Locker "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}"
attrib +h +s "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "enterpasswordhere=>"
if NOT %enterpasswordhere%==type your password here goto FAIL
attrib -h -s "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}"
ren "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}" Locker
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:End
Now as you may see, if you go through the code there is a section that says "enterpasswordhere" This is where you change it to whatever password you'd like to use.
Last, save your notepad as whatever you want.bat.
An example could be..
PasswordProtection.bat
This turns it into a bat file, making the code work.
Now I know you must be wondering "But what does this all do???" I'll explain.
Now, at the start of the code, the batch file looks for the folder named "Locker". If it cannot find one it will create one for you. After it has found this folder, it will ask you if you'd like to lock it. Type y or Y and press enter to lock the folder. What this does, is it renames the folder "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}" and gives it the properties of the recycle bin. This means that the folder you just had your programs will turn into the recycle bin shortcut. If you open the new shortcut, you will be brought to the recycle bin, hence your files are hidden.
Now to unlock your files, you have to open the batch file again. Instead of finding "Locker" it will find "Recyle Bin.{645FF040-5081-101B-9F08-00AA002F954E}" (The file that was just locked) Then it will ask you for the password you entered inside of the code. You had to have replaced "enterpasswordhere" in BOTH spots for this to work correctly. What it does, is ask for the password. If the password is correct, it will change the folder back to the name "Locker" and you can open it once again. Check for yourself, your files are still there! Voila! Your files are password protected!
I hope this comes in handy! Try it yourself! Have fun! :]
First off, make a folder named "Locker" and place whatever files you want to protect in this folder.
Next, open a notepad and enter the following code inside.
cls
@ECHO OFF
title Folder Locker
if EXIST "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Locker "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}"
attrib +h +s "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "enterpasswordhere=>"
if NOT %enterpasswordhere%==type your password here goto FAIL
attrib -h -s "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}"
ren "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}" Locker
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:End
Now as you may see, if you go through the code there is a section that says "enterpasswordhere" This is where you change it to whatever password you'd like to use.
Last, save your notepad as whatever you want.bat.
An example could be..
PasswordProtection.bat
This turns it into a bat file, making the code work.
Now I know you must be wondering "But what does this all do???" I'll explain.
Now, at the start of the code, the batch file looks for the folder named "Locker". If it cannot find one it will create one for you. After it has found this folder, it will ask you if you'd like to lock it. Type y or Y and press enter to lock the folder. What this does, is it renames the folder "Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}" and gives it the properties of the recycle bin. This means that the folder you just had your programs will turn into the recycle bin shortcut. If you open the new shortcut, you will be brought to the recycle bin, hence your files are hidden.
Now to unlock your files, you have to open the batch file again. Instead of finding "Locker" it will find "Recyle Bin.{645FF040-5081-101B-9F08-00AA002F954E}" (The file that was just locked) Then it will ask you for the password you entered inside of the code. You had to have replaced "enterpasswordhere" in BOTH spots for this to work correctly. What it does, is ask for the password. If the password is correct, it will change the folder back to the name "Locker" and you can open it once again. Check for yourself, your files are still there! Voila! Your files are password protected!
I hope this comes in handy! Try it yourself! Have fun! :]