Password Protecting a Folder

This basic security feature allows you to protect sensitive files from the casual snooper. For example, hiding your Christmas present list from the family. It won’t keep out the tech savy but it is better that nothing.

This tutorial was based on information in a Microsoft blog.

First create a folder for your sensitive files and add a text file. This will become a batch file a little later.

Create folder and text file

Now add the batch program text:

REM === Protect Folder ===
REM === Change colours ===
color 0A
cls
@ECHO OFF
REM === Set window title ===
TITLE Protect Folder
REM === Test for existing folder ===
if EXIST “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
REM === Select option ===
ECHO Protect the folder(Y/N)
set/p “opt=>”
if %opt%==Y goto LOCK
if %opt%==y goto LOCK
if %opt%==n goto END
if %opt%==N goto END
ECHO Invalid option
goto CONFIRM
REM === Protect the folder ===
:LOCK
ren Locker “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
attrib +h +s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
ECHO Folder protected
ECHO Run again to unprotect
goto END
REM === Unprotect the folder ===
:UNLOCK
ECHO Enter password to Unlock folder
set/p “pass=>”
REM === Replace PASSWORD with your password ===
if NOT %pass%==PASSWORD goto FAIL
attrib -h -s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
ren “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” Locker
ECHO Folder Unprotected
ECHO Add / edit sensitive files and run again to protect
goto End
REM === Wrong Password ===
:FAIL
ECHO Invalid password
goto END
REM === Create Locker Folder ===
:MDLOCKER
REM === Change folder name if you like ===
md Locker
ECHO Locker created successfully
ECHO Put sensitive files into it and run again to protect
:END
PAUSE

Change the password if required, it can be found on this line.

if NOT %pass%==PASSWORD goto FAIL

Save the batch file with a name of your choice.

The first run of the batch file should create a folder called Locker within your folder.

Move your sensitive files into the Locker folder. The next run will ask if you want to protect the Folder

Typing Y or y will protect the folder. In other word it will disapear from the containing folder. When you need the files again the next run will unprotect the folder.

The batch file can be edited and the password is in plain text so it isn’t secure to leave it in the containing folder. You could move it to a USB stick or use a BAT to EXE convertor program. Or even write your own program.

Link to original Microsoft blog

Leave a Reply

Your email address will not be published. Required fields are marked *