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:
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:
- @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 u 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.
- goto CONFIRM115
- :LOCK
- ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
- attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
- echo Folder locked
- goto End
- :UNLOCK
- echo Enter password to Unlock folder
- set/p "pass=>"
- admin
- if NOT %pass%== secret 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
- goto End
- :FAIL
- echo Invalid password
- goto end
- :MDLOCKER
- md Locker
- echo Locker created successfully
- goto End
Thanks.
No comments:
Post a Comment