In this post, I am going to tell you how to lock your folders in PC. This is the second part of the previous post.

Haven’t you read our previous post? How to password protect a folder in PC |Part 1|.

This second part is a little bit confusing, but not so much difficult.

Code to lock a folder on PC

This code is better than the previous one. But again let me remind you, anyone with knowledge of batch files can easily break into your folder.

Let’s start:

  • Open notepad.
  • Copy and paste following code into notepad.

@echo off
title Zask’s password encrypted batch file
color 0a

echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º Zask’s password encrypted batch file º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.

if not exist “C:\Pswrd.Zask\” (
mkdir “C:\Pswrd.Zask\”
if “!errorlevel!” EQU “0” (
goto DirectoryExist
) else (
echo Created the folder “C:\Pswrd.Zask” & timeout /t 5 /nobreak
)
) else (
goto DirectoryExist
)

:DirectoryExist

if exist C:\Pswrd.Zask\Key.Zask (
goto UsernameExist
) else (
goto CreatePasswordScreen
)

:UsernameExist

for /f “Delims=” %%A in (C:\Pswrd.Zask\Password.Zask) do (
set CHECKPASSWORD=%%A
)
for /f “Delims=” %%B in (C:\Pswrd.Zask\Key.Zask) do (
set CHECKKEY=%%B
)

goto PasswordScreen

:CreatePasswordScreen
cls
echo Create a password.
echo.

setlocal EnableDelayedExpansion

set /p “CREATEPASSWORD= Enter password : ”
set /p “CREATEKEY= Enter a key number (Choose a number 2-200) : ”

set CHAR=0123456789bhfcjrwmudaxopvntzlqeisykg

for /l %%C in (10 1 36) do (

for /f %%D in (“!CHAR:~%%C,1!”) do (

set /a MATH=%%C*%CREATEKEY%
for /f %%E in (“!MATH!”) do (

set “CREATEPASSWORD=!CREATEPASSWORD:%%D=-%%E!”

)
)
)

echo %CREATEPASSWORD% >> C:\Pswrd.Zask\Password.Zask
attrib C:\Pswrd.Zask\Password.Zask +s +h & echo. & echo Password Created!

echo %CREATEKEY% >> C:\Pswrd.Zask\Key.Zask
attrib C:\Pswrd.Zask\Key.Zask +s +h & echo Username Created!
echo.

if exist “%~dp0ResetPassword.bat” (
del “%~dp0ResetPassword.bat” )

:ResetPassword
set /p “RESETOPTION=Would you like to create the password options file in the current directory (Y/N)? : ”
if /i %RESETOPTION%==Y goto ResetOptions
if /i %RESETOPTION%==N goto SkipResetOptions

:ResetOptions
echo @echo off >> PasswordOptions.bat
echo title ResetPassword.bat >> PasswordOptions.bat
echo color 0a >> PasswordOptions.bat
echo :start >> PasswordOptions.bat
echo. >> PasswordOptions.bat
echo echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» >> PasswordOptions.bat
echo echo º This file is used to reset your password, hide it for future purposes or delete it º >> PasswordOptions.bat
echo echo º to avoid other users from removing your password. You have 5 options º >> PasswordOptions.bat
echo echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ >> PasswordOptions.bat
echo echo. >> PasswordOptions.bat
echo echo 1 – Reset password. >> PasswordOptions.bat
echo echo 2 – Open password folder. >> PasswordOptions.bat
echo echo 3 – Unhide files in the password folder. >> PasswordOptions.bat
echo echo 4 – Hide files in the password folder. >> PasswordOptions.bat
echo echo 5 – Exit dialog. >> PasswordOptions.bat
echo echo. >> PasswordOptions.bat
echo set /p “OPTIONS=Chose a number to select that option : ” >> PasswordOptions.bat
echo if %%OPTIONS%%==1 goto PasswordReset >> PasswordOptions.bat
echo if %%OPTIONS%%==2 start C:\Pswrd.Zask ^& cls ^& goto start >> PasswordOptions.bat
echo if %%OPTIONS%%==3 attrib C:\Pswrd.Zask\Password.Zask -s -h ^& attrib C:\Pswrd.Zask\Key.Zask -s -h ^& cls ^& goto start >> PasswordOptions.bat
echo if %%OPTIONS%%==4 attrib C:\Pswrd.Zask\Password.Zask +s +h ^& attrib C:\Pswrd.Zask\Key.Zask +s +h ^& cls ^& goto start >> PasswordOptions.bat
echo if %%OPTIONS%%==5 exit >> PasswordOptions.bat
echo. >> PasswordOptions.bat
echo :PasswordReset >> PasswordOptions.bat
echo cls >> PasswordOptions.bat
echo set /p “RESET=Are you sure you want to reset your password (Y/N)? : ” >> PasswordOptions.bat
echo if /i %%RESET%%==Y goto ResetPassword >> PasswordOptions.bat
echo if /i %%RESET%%==N goto start >> PasswordOptions.bat
echo cls >> PasswordOptions.bat
echo. >> PasswordOptions.bat
echo :ResetPassword >> PasswordOptions.bat
echo rd /s /q “C:\Pswrd.Zask” >> PasswordOptions.bat
echo echo Password was deleted! >> PasswordOptions.bat
echo pause >> PasswordOptions.bat
echo del %%~n0%%~x0 >> PasswordOptions.bat
echo exit >> PasswordOptions.bat
cls

echo. & echo Created file “%~dp0ResetPassword.bat” & timeout /t 5 /nobreak

:SkipResetOptions

start %~n0%~x0
exit

:PasswordScreen
color 0a
cls
echo Existing User Account.
echo.

setlocal EnableDelayedExpansion

set /p “PASSWORD= Enter Password : ”
set /p “KEY= Enter the original encryption key : ”

set CHAR=0123456789bhfcjrwmudaxopvntzlqeisykg

for /l %%C in (10 1 36) do (

for /f %%D in (“!CHAR:~%%C,1!”) do (

set /a MATH=%%C*%CHECKKEY%
for /f %%E in (“!MATH!”) do (

set “CHECKPASSWORD=!CHECKPASSWORD:%%E=%%D!”

)
)
)

for /f %%F in (“!CHECKPASSWORD!”) do (
set “CHECKPASSWORD=!CHECKPASSWORD:-=!”

)

if %PASSWORD%==%CHECKPASSWORD% (
goto Operation1True
) else (
goto OperationFalse
)

:Operation1True
if %KEY%==%CHECKKEY% (
goto Operation2True
) else (
goto OperationFalse
)

:OperationFalse
color 0c
echo Password Incorrect!
timeout /t 10 /nobreak
goto PasswordScreen

:Operation2True
cls
if EXIST “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” goto UNLOCK
if NOT EXIST dontOpenIt goto MDLOCKER
:CONFIRM
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.
goto CONFIRM
:LOCK
ren dontOpenIt “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
attrib +h +s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
echo Folder locked
goto End
:UNLOCK
attrib -h -s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
ren “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” dontOpenIt
echo Folder Unlocked successfully
goto End
:MDLOCKER
md dontOpenIt
echo Private created successfully
goto End
:End

REM YOUR CODE GOES HERE.
REM YOU CAN CONVERT THIS IS INTO A EXE FILE IF WANTED.


  • Now save the file name “Secure.bat”. You can change the name “Secure” to anything.
  • Select the file type as “All files”
  • Hit the enter key to save the program.

Read More: IAEA training

Setup

Since you have saved the code, let’s set up it.

  • Open the program.
  • Now, create a password.
  • Now, create a key. (second layer of protection)
  • It will ask “Would you like to create password options files?”
  • Type “Y” and hit enter.
  • It will create another program which can be used to change password, you may delete if you do not want to change password. Or you may hide it. How?? Once deleted, no one can change password.
  • Again, fill in the newly created “password and key”.
  • It will create a new folder. Put your data into this folder.
  • Now open the program again and fill in the password and key.
  • It will ask you permission to lock the folder. Type “y” and hit enter.

All done! when you want to access your folder open the program and fill in the password to unlock your folder.

What’s different here?

The difference between our previous post and this post is:

In the previous post, one can easily see the password by clicking on edit. But here the password is created and save to C drive.

When you navigate to C drive you can see a new folder name “pswrd.zask”. And when you open the folder, you would find the folder empty. So there is no way to get the password.

But your folder can still be opened by other means. It is still better than the previous method because even a programmer would take some time to understand and then unlock your folder.

Give us a Moment!

It will hardly take 1 minute to complete our survey. It only consists of 6 short questions. Please complete it so that we can make some great experiences. Click here to proceed.

Please help us to Grow. We try to provide best and reliable data for our users. We cannot do it without your help. You can help us even by telling some suggestions, correction and adding something useful to our Post


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *