How To Lock / Unlock Password Protected Folder Using BAT File

Have you ever wish you could lock and unlock folder so you could hide your important files without using folder properties? Now you could using BAT File. It’s a simple programming technique which will help you to rename folder and treat it as a hidden file or redirect user to control panel folder. In this tutorial I use Control Panel as a folder name because once it has been activated, windows will redirect user to control panel. You can replace folder name as you like it but i would suggest to keep it that way. Password can also be set by editing the BAT file in a notepad editor, just remember to save it as “BAT” file. Note: enclose the filename with quotation marks to save it as BAT file, eg. “Lock.BAT”. In that way, notepad will save as BAT rather than TXT File.

<<<<Start of Code>>>



title Control_Panel

if EXIST “Control_Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” goto UNLOCK

if NOT EXIST Control_Panel goto MDLOCKER


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.



ren Control_Panel “Control_Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”

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

echo Folder locked

goto End


echo Enter password to unlock folder

set/p “pass=>”

if NOT %pass%== 032003 goto FAIL

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

ren “Control_Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” Control_Panel

echo Folder Unlocked successfully

goto End


echo Invalid password

goto end


md Control_Panel

echo Control_Panel created successfully

goto End


<<<<End of Code>>>

By |2018-04-10T10:51:04+00:00April 27th, 2012|Tools, Tutorials|