Skip to content

How to secure a folder on Windows with a password?

  • by
  • 4 min read

Tired of friends and family trying to access your personal files and folders on your laptop or PC whenever an opportunity presents itself? Wish to keep their prying eyes off of your personal data? Don’t worry, we’ve got you covered.

Here, we offer a straightforward and effective way using which you can password protect your folders in Windows.

Step 1

Right-click in the folder area of the file you want to secure and select New -> Text Document.

How to secure a folder on Windows with a password?

Step 2

Inside the text file, copy and paste the following code:

How to secure a folder on Windows with a password?

cls

@ECHO OFF

title Folder Locker

if EXIST “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” 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 “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%==Your-Password-Here goto FAIL

attrib -h -s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”

ren “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” Locker

echo Folder Unlocked successfully

goto End

:FAIL

echo Invalid password

goto end

:MDLOCKER

md Locker

echo Locker created successfully

goto End

:End

Locate the Your-Password-Here (highlighted) text on the file and set the password of your preference here and save it as a .bat file under the name of your liking.

How to secure a folder on Windows with a password?

This batch (.bat) file has commands that run serially on the command prompt (cmd) providing an efficient way using which you can secure your folders containing personal data by setting a password for it.

How to secure a folder on Windows with a password?

Step 3

Double click on the saved .bat file and a Locker folder will be created. Store all the data you’d like to protect in it.

How to secure a folder on Windows with a password?

Note: You can change the name of this Locker file by making the necessary changes in the code itself. Replace ‘Locker’ (highlighted) at the top of the code. Do not use the standard renaming technique for this as the code does not anticipate the changes in the name of the folder, leaving your file unprotected after that.

How to secure a folder on Windows with a password?

Step 4

It’s time to lock the file. Double click on the .bat file again and a confirmation message will be displayed on the command prompt.

How to secure a folder on Windows with a password?

Type ‘Y’. The Locker folder will disappear after this action.

How to secure a folder on Windows with a password?

Step 5

If you want to access your files hereafter, just double click on the .bat file and type in the correct password when prompted.

How to secure a folder on Windows with a password?

The problem in this method is that if someone checks the .bat file in that folder:

  1. They’d know you have a secret locker in that folder
  2. They could try to guess the password
  3. If they happen to delete this .bat file, your Locker’s data will be inaccessible to you forever

How to secure a folder on Windows with a password?

For the above reasons, you can hide the .bat file, making private data inconspicuous to the adversary and thus prevent them from accessing your files.

How to secure a folder on Windows with a password?

Select the .bat file and go to View-> Hide selected File.

How to secure a folder on Windows with a password?

After this, whenever you want to reaccess the .bat file, in View tick the Hidden items checkbox. Remember to keep the Hidden items checkbox unticked anytime other than the times you want to access your data.

Parinita Haldar

Parinita Haldar

>