Can anyone help me with this code?

(This is with notepad and saved as .bat)

I’m trying to lock a document on my windows 10 computer, and it works but you can also get access to the “hidden” folder with wrong password. Does anyone know how to make a line of code that doesn’t allow wrong password to open the “hidden” folder. Here is the code:

if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Private goto MDPrivate
echo Are you sure to lock this 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.
ren Private "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
echo Enter password to Unlock Your Secure Folder
set/p "pass=>"
if NOT %pass%== wonderhowtogoto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Private
echo Folder Unlocked successfully
goto End
echo Invalid password
goto end
md Private
echo Private created successfully
goto End

There is a lot of discussion about this script here:

Also some question as to if it really works or not. Biggest issue seems to be in your present version you can just open the bat file and magically have the password, so not really secure unless you delete the bat every time.

However some others appear to have offered code variants as well. You might have a look.

1 Like

a space is missing after your password and goto statement
if NOT %pass%== wonderhowtogoto FAIL replace with
if NOT %pass%== wonderhowto goto FAIL