Technical Forums (Troubleshooting)

This will provide you easy trouble shooting.

Tuesday, October 4, 2011

How to lock Folder in Windows

If you want locking up your folder with a password, so the user who
knows the right password can only be able to access the folder, where others don’t (Well this is not quite
secure, but can be useful in learning batch programming, because even a noob can easily identify the
password, or can access the folder without using a password, there are a lot of ways to break it).
The batch file that is given below will create a directory named ‘Locker’, when it gets executed,
then you may place whatever you wish to place inside that directory, once done re-execute the same batch
file, then it will prompt you whether to lock the folder,  like this
press ‘y’ and hit enter, then the directory ‘Locker’ Disappears. In order to make the directory re-appear
again, you have to execute the same batch file once again, then it will prompt you to enter the password to
unlock the folder, you have to enter the password as ‘secret’, since it is already mentioned by default in
the program itself.
Once the password is matched, then the folder becomes visible, so that you can access the folder again.
So, what happens is that, the folder ‘Locker’ is set with the system and hidden attribute, hence it becomes
invisible, when the batch program is executed again, it prompt for password, which is already set as an
environment variable with a value ‘secret’, when the match is found, the attribute is set to normal and the
folder becomes visible and accessible.
Here is the snippet for the folder locke.
Copy , paste this code on notepad and save as with bat extension (like lock.bat). 
 
Script:
  1. @echo off
  2. title Folder Locker
  3. if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
  4. if NOT EXIST Locker goto MDLOCKER
  5. :CONFIRM
  6. echo Are you sure u want to Lock the folder(Y/N)
  7. set/"cho=>"
  8. if %cho%==Y goto LOCK
  9. if %cho%==y goto LOCK
  10. if %cho%==n goto END
  11. if %cho%==N goto END
  12. echo Invalid choice.
  13. goto CONFIRM115
  14. :LOCK
  15. ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
  16. attrib ++"Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
  17. echo Folder locked
  18. goto End
  19. :UNLOCK
  20. echo Enter password to Unlock folder
  21. set/"pass=>"
  22. admin
  23. if NOT %pass%== secret goto FAIL
  24. attrib --"Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
  25. ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
  26. echo Folder Unlocked successfully
  27. goto End
  28. :FAIL
  29. echo Invalid password
  30. goto end
  31. :MDLOCKER
  32. md Locker
  33. echo Locker created successfully
  34. goto End
Thanks.

No comments:

Post a Comment