I used a tutorial at this link for protecting one of my important files,
The CODE is:
cls
#ECHO OFF
title coolhacking-tricks.blogspot.com
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto
UNLOCK
if NOT EXIST MyFolder goto MDMyFolder
:CONFIRM
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.
goto CONFIRM
:LOCK
ren MyFolder "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 Your Secure Folder
set/p "pass=>"
if NOT %pass%== coolhacks goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" MyFolder
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDMyFolder
md MyFolder
echo MyFolder created successfully
goto End
:End
But when I run lock.bat I don't get a screen asking for a password. Instead a screen appears and states: "the system cannot find the batch label specified" and suddenly the screen disappears without waiting a fraction of a second. The uploader was unable to help me with my problem.
Run this in the the root folder of your drive (assuming your script used the same GUID as the script on that page):
dir /b /s /a:s *.{21EC2020-3AEA-1069-A2DD-08002B30309D}
It'll take less time if you can narrow down the location to a particular parent folder.
Unhide the folder with these two commands:
attrib -s -h "C:\path\to\Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "C:\path\to\Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" newname
And next time steer clear of crappy "security tools" like that. It doesn't password-protect anything in the first place. It merely renames a folder an sets the hidden and system attributes.
Maybe use this (but re:
cls
#ECHO OFF
title Folder Private
if EXIST "HTG Locker" goto UNLOCK
if NOT EXIST Private 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 Private "HTG Locker"
attrib +h +s "HTG Locker"
echo Folder locked
goto End
:UNLOCK
echo Enter password to unlock folder
set/p "pass=>"
if NOT %pass%== beef goto FAIL
attrib -h -s "HTG Locker"
ren "HTG Locker" Private
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Private
echo Private created successfully
goto End
:End
Related
I have a batch file which hids a folder. It has been working for years but has suddenly stopped working and I can't work out why.
#ECHO OFF
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Private goto MDPrivate
:CONFIRM
echo Are you sure you want 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.
goto CONFIRM
:LOCK
ren Private "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 Your Secure Folder
set/p "pass=>"
if NOT %pass%== takingcareofbusiness goto 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
:FAIL
echo Invalid password
goto end
:MDPrivate
md Private
echo Private created successfully
goto End
:End
The problem initially presents as a problem with the attrib settings not being applied in the LOCK section but on further investigation (putting an echo after the ren command), the batch file closes after the ren command.
What's even more weird is that is runs perfectly well in Command Prompt but not when running it from Windows Explorer.
User has Administrator priviledge but it just stops working.
Completely untested as I am not even on my Windows device. but some things to note. Do not use set /p when dealing with choice selection. You can use choice.exe for that.
When comparing items using if always follow the trend on both sides by matching exactly between double quotes. i.e if "var" == "%var%"
#ECHO OFF
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST "Private" goto MDPrivate
choice /c yn /m "echo Are you sure you want to lock this folder?"
if errorlevel 2 goto :EOF
ren "Private" "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto :EOF
:UNLOCK
echo Enter password to Unlock Your Secure Folder
set/p "pass=>"
if NOT "%pass%" == "takingcareofbusiness" goto 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 :EOF
:FAIL
echo Invalid password
goto :EOF
:MDPrivate
md Private
echo Private created successfully
A while back, I found this code to create a batch file that puts a password lock on a folder.
#ECHO OFF
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Private goto MDPrivate
:CONFIRM
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.
goto CONFIRM
:LOCK
ren Private "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 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
:FAIL
echo Invalid password
goto end
:MDPrivate
md Private
echo Private created successfully
goto End
:End
Today, the file got corrupted and it continues to give me the message "The filename, directory name, or volume label syntax is incorrect." when I try to open it with the command prompt. I'm trying to find out if there is a way to either fix the batch file, or locate the locked folder so I can just transfer it to a hard drive and store it away. Any help is appreciated.
They're still in the folder. It's just renamed so that Windows Explorer can't open it. To manually unlock it, run these commands from it:
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Private
cls
#ECHO OFF
color 0c
title Folder Secure
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Secure 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 Secure "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 the Password to unlock folder
set/p "pass=>"
if NOT %pass%== access1221 goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Secure
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Secure
echo Secure created successfully
goto End
:End
Can someone edit this to hide the inputted password with asterisks. Most of the entries i saw used a long method which did not seem to be compatible with this particular program.
Thanks.
I have this code snippet from a Stack Overflow question about masking input in a batch script.
set "psCommand=powershell -Command "$pword = read-host 'Enter Password' -AsSecureString ; ^
$BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
for /f "usebackq delims=" %%p in (`%psCommand%`) do set password=%%p
echo %password%
And here is my script.
cls
#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 CONFIRM
: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=>"
if NOT %pass%==Your-Password-Here 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
:End
Now, I want to implement the code snippet I showed earlier into my own script, where should I put the snippet into the script? Should I remove some code or not?
in this batch file i am trying to created a program where the user can enter his or her desired password and use it when ever they open or close the Batch file.
the problem is that i can not get the user password and (at :MDLOCKER and :UNLOCK) and the unlock part of the script to work. when finally get it to work it accepts any password
if you could help that would be great thanks.
enter code here#ECHO OFF
prompt Filelocker`enter code here`
:START
echo what do you want to do? (insert number)
echo 1 Lock current folder
echo 2 Unlock current folder
echo 3 Make new locked folder
set/p "cho=>"
if %cho%==1 goto CONFIRM
if %cho%==2 goto UNLOCK
if %cho%==3 goto NEW
echo not valid
goto start
: NEW
title Folder Locked files
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto ALREADY
if NOT EXIST Locker goto MDLOCKER
:ALREADY
echo folder already exist!
echo try unlocking if folder can not be found
pause
goto START
: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 CONFIRM
: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
:MDLOCKER
md Locker
echo Locked folder created....
echo folder is now created
echo enter password for your file.
set/p 1%=
echo password accepted
goto start
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass%==%1% 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
echo 2 MORE TRYS LEFT
pause
goto
:End
I don't think you can change the positional parameters %1 .. %9. Try saving your password into a variable instead.
the problem is here:
set/p 1%=
Why are you doing that?
You can't use a special var like a var-name.
And you can't use numbers at the start of a var-name.
and you can use the command Choice instead of all the IF statements that you are using:
#ECHO OFF
prompt Filelocker`enter code here`
:START
echo what do you want to do? (insert number)
echo 1 Lock current folder
echo 2 Unlock current folder
echo 3 Make new locked folder
choice /C 123 /M "choose an option: "
IF %ERRORLEVEL% EQU 1 (goto :CONFIRM)
IF %ERRORLEVEL% EQU 2 (goto :UNLOCK)
IF %ERRORLEVEL% EQU 3 (goto :NEW)
:NEW
title Folder Locked files
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" (
echo folder already exist!
echo try unlocking if folder can not be found
pause
goto :START
)
if NOT EXIST "Locker" (goto :MDLOCKER)
:CONFIRM
choice /C YN /M "Are you sure u want to Lock the folder? "
IF %ERRORLEVEL% EQU 1 (goto :LOCK)
IF %ERRORLEVEL% EQU 2 (goto :END)
: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
:MDLOCKER
md "Locker"
echo Locked folder created....
echo folder is now created
echo enter password for your file.
set/p "VAR=>> "
echo password accepted
goto :start
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>> "
if NOT "%pass%"=="%VAR%" 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
echo 2 MORE TRYS LEFT
pause
goto :UNLOCK
:End