Monday, 6 October 2014

Creating a Bat File

How To Create a Password Protected Folder in Windows 7
DE
1. First choose or create a folder and give it a name.


2. Open the folder by double left clicking it and then right click anywhere within the open folder and select “New” then “Text Document


3. Rename your newly created text file to 'Password.bat' (make sure the file extension is .bat - not .bat.txt)

Note: that you need to have file extensions view enabled in Windows in order to rename the .txt extension to .bat. Please follow the first to steps of the tutorial HERE if you do not know how to enable it.

4. Right click on the file password.bat and select 'Edit' this will open the file in Notepad.

5. Highlight and Copy the below text and then paste it into the Password.bat file:



@ECHO OFF
title Folder Private
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Private goto MDLOCKER
:CONFIRM
echo Are you sure you 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 Private "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to unlock folder
set/p "pass=>"
if NOT %pass%==
 ENTER YOUR PASSWORD HERE goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Private
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Private
echo Private created successfully
goto End
:End



6. Replace the text in the above script 'ENTER YOUR PASSWORD HERE' with your choice of password - it's best if it is something memorable and unique. Save the file by left clicking 'File' and selecting 'Save' in Notepad and close the file.


7. Now double left click on the password.bat file in the folder and this will create a Private folder. Simply 'copy and paste' the documents/data you want to protect into this Private folder. 

8. Once you are finished copying/pasting your documents/data into the Private folder double left click thepassword.bat file and you will get prompted with: “Are You Sure You Want To Lock The Folder Y/N” - type Y and hit the enter/return key. The Private folder will disappear. It is wise to move the password.bat file to a different location on your computer or on a USB memory stick - as most people who are literate with Windows and bat(ch) files will be able to figure out how to open the password.bat file by right clicking it and selecting 'Edit', which will then reveal your password.

9. If you want the Private folder to reappear - simply move the password.bat file back into the original folder you created, and double left click on the password.bat file, when prompted - enter your password and hit enter/return key - like magic the Private folder will appear once again. Use this technique to Lock/Unlock the file as required.

No comments:

Post a Comment