How to Give a Password to a File or Folder in CMD without Using Any Software

By Jeffrey Chen

There may be things on a computer that are sensitive that people should not see. Most people can find things just by snooping around if they have general knowledge of computers. Having a password-protected folder will work wonders against people and keep documents and files safe from prying eyes.

Things You'll Need

  • Notepad

Locking a Folder

Step 1

Open up notepad and paste the following code into OFFecho // Check1 (In Main Function)title Folder LockFolderif EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLockFolderif NOT EXIST LockFolder goto MDLockFolder:AuthConfirmecho Are you sure u want to Lock Folder (Y/N)set/p "cho=>"if %cho%==Y goto LockFolderif %cho%==y goto LockFolderif %cho%==n goto ENDif %cho%==N goto ENDecho Invalid choice.goto AuthConfirm:LockFolderren LockFolder "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"echo Folder LockFolder Locked!goto End:UNLockFolderecho Enter password to Unlock Folderset/p "pass=>"if NOT %pass%==TYPE YOUR PASSWORD HERE goto FailUnlockattrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" LockFolderecho Folder UnLocked successfully!goto End:FailUnlockecho Invalid password!echo Try again? (Y/N)set/p "choice=>"if %choice%==Y goto UNLockFolderif %choice%==y goto UNLockFolderif %choice%==N goto ENDif %choice%==n goto END:MDLockFolderecho // Check2 (In MD Dir Function)md LockFolderecho Folder LockFolder created successfully!goto End:EndPut the password where it says "TYPE YOUR PASSWORD HERE."

Step 2

Save the file as locker.bat by clicking "File," "Save As," and at the bottom, where it says .txt, change to "All Files."

Step 3

Open locker.bat and enter your password. It will create a new folder that will be password-protected from now on.