DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Batch Code To Make Win Folder Hidden And Password Protected

  • submit to reddit
        Open any text editor and copy the the contents of this code to a text file and save it with any name having .bat extension.

echo 			// Check1 (In Main Function)
title Folder LockFolder
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLockFolder
if NOT EXIST LockFolder goto MDLockFolder
echo Are you sure u want to Lock Folder  (Y/N)
set/p "cho=>"
if %cho%==Y goto LockFolder
if %cho%==y goto LockFolder
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto AuthConfirm
ren LockFolder "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder LockFolder Locked!
goto End
echo Enter password to Unlock Folder
set/p "pass=>"
if NOT %pass%==TYPE YOUR PASSWORD HERE goto FailUnlock
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" LockFolder
echo Folder UnLocked successfully!
goto End
echo Invalid password!
echo Try again?  (Y/N)
set/p "choice=>"
if %choice%==Y goto UNLockFolder
if %choice%==y goto UNLockFolder
if %choice%==N goto END
if %choice%==n goto END
echo 			// Check2 (In MD Dir Function)
md LockFolder
echo Folder LockFolder created successfully!
goto End