Do you have items you want to keep hidden on your computer? Creating a locked folder using a batch script is a fun and easy way to hide files in low-stakes situations that don't require files to be encrypted. This Nice Institutes teaches you how to create a locker folder using a batch file

How to Lock a Folder Using a Batch File

1
Open Notepad.
Notepad has an icon that resembles a blue notebook folder. Use the following steps to open Notepad:
step1:-Click the Windows Start Menu.
step2:-Type “Notepad.”
step3:-Click Notepad.

2

select and 
Copy the following batch script.

The batch script is in the box below. Highlight the entire script. Right-click it and click Copy, or press “Ctrl + C.” The script is as follows

				
					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 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.

timeout 1

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

timeout 3

goto End

:UNLOCK

@echo off
set "psCommand=powershell -Command "$pword = read-host 'Enter Password to Unlock folder' -AsSecureString ; ^
    $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
        [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
for /f "usebackq delims=" %%p in (`%psCommand%`) do set password=%%p

if NOT %password%==TYPE_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

timeout 1

goto End

:FAIL

echo Invalid Password

timeout 1

goto end

:MDLOCKER

md Locker

echo Locker created successfully

timeout 5

goto End

:End
				
			
3
Paste the code into Notepad.
 Go back to your blank Notepad document. Right-click at the top of the page and click Paste, or press “Ctrl + V” to paste the code into Notepad.
Change the password. Locate where it says “TYPE_YOUR_PASSWORD_HERE” in the script. It’s about three-quarters of the way down. It’s in the line that starts with “if NOT %password%==”.
 
5
Save the document as a batch file. Use the following steps to save the Notepad document as a batch file:
  • Click File.
  • Click Save as.
  • Click the drop-down menu next to “Save as type.”
  • Select All files (*.*).
  • Type a file name in the File Name field (i.e. ram).
  • Type “.bat” at the end of the file name (I.e. ram.bat).
  • Click Save.
6
Close the window. Once you are finished saving the Batch file, you can close Notepad.
7
Run the batch file by double-clicking it. Navigate to where you saved the batch file in File Explorer. Double-click the batch file to run it. This will create a new folder called “Locker” in the same folder as the batch file.
8
Move all the things you want to hide into the Locker folder. You can move objects into the folder by dragging and dropping them, or you can copy and paste them into the folder.
9
Double-click on the locker.bat file again. A Command Prompt will open. It will ask you if you want to lock the folder.
10
Press Y and then press  Enter. The Locker folder will disappear from the folder. This indicates it is locked.
11
Unlock the folder. When you want to gain access to the folder again, use the following steps to make the Locker folder reappear:
  • Double-click the batch file to run it.
  • Enter the password you input into the batch file before you saved it.
  • Press the Enter key.

Tips

  • Set the batch file attribute to “hidden” so it will not show up in a standard File Explorer window. You will need to set File Explorer to show hidden files and folders to view the batch file.

  • For a more robust method of password protecting folders, try using Axcrypt, Windows Bitlocker. Bitlocker is available on Windows 10 Pro, Enterprise, and Education editions. Axcrypt is a third-party encryption program that works on all versions of Windows.

Warnings

  • Programs like 7zip File Manager will be able to access the folder.

  • Do not rename the file after it is secured. It will no longer be protected.

  • Windows Search could find it the hidden folder.

  • Be aware that anyone who can access the batch file can edit it in Notepad and find out the password.