@echo off && setlocal enabledelayedexpansion
<con: cd /d "%~dp0" & color 0a && mode 60,8
title<nul & title Folder Lock/unLock Script && >nul chcp 65001
set "_crtl_panel=control panel.{21ec2020-3aea-1069-a2dd-08002b30309d}"
Certutil -decode -f "%~f0" "%temp%\2L.bin" >nul 2>&1 && goto:next || goto:fail
:: < -----BEGIN 2L.bin----- G1sxRhtbMEobWzFGG1swSg0K -----END 2L.bin----- > ::
:next
if exist "!_crtl_panel!" (goto=:unlock)else if exist Cofre (
goto=:confirm) else goto=:mdCofre
:confirm
echo\ & set /p _yn=Pretende Bloquear Sua Pasta [s/n]:
if /i "!_yn!"=="s" (goto=:lock) else if /i "!_yn!"=="n" (
endlocal && goto=:EOF)else echo\Escolha inválida.
timeout -1 & cls & set "_yn=" & goto=:confirm
:lock
<con: rename .\Cofre "!_crtl_panel!" && attrib +h +s "!_crtl_panel!"
dir/a:d "!_crtl_panel!" >nul && echo\Pasta Bloqueada && timeout -1 && goto=:EOF
echo\Erro ao Bloquear Pasta...& timeout -1 & endlocal && goto=:EOF
:unlock
echo\ & set /p "=_" < nul > "Digite a Senha Para Desbloquear Pasta "
findstr /A:1E /V "^$" "Digite a Senha Para Desbloquear Pasta " nul >con
del "Digite a Senha Para Desbloquear Pasta " && set /P "_pass="
color 0a & type "%temp%\2l.bin" & >nul 2>&1 del/q /f "%temp%\2l.bin"
for %%i in (reinstall,"listsize=0","listsize=50")do doskey.exe /%%~i
if !_pass! equ 123456 2>nul (
attrib -h -s ".\!_crtl_panel!"
rename ".\!_crtl_panel!" Cofre
dir/a:d Cofre >nul && echo\Pasta Desbloqueada Com Sucesso
goto=:EOF)else Echo\Acesso Negado && goto=:fail
:fail
echo\ & echo\Senha inválida && timeout -1 & goto=:EOF
:mdCofre
echo\ && mkdir Cofre && echo\Cofre Criado Com Sucesso && endlocal && goto:eof
To mask an input into a bat, you can use the solution of @Aacini in this reply, where a findstr
is used interchangeably with a set /p
already omitting input/password entry:
set /p "=_" < nul > "Digite a Senha Para Desbloquear Pasta "
findstr /A:1E /V "^$" "Digite a Senha Para Desbloquear Pasta " nul >con
del "Digite a Senha Para Desbloquear Pasta " && set /P "_pass="
To delete/remove the line typed in the input/password, this solution @Lotpings in this reply // with an adaptation suggesting the use of Base64
Certutil -decode -f "%~f0" "%temp%\2L.bin" >nul 2>&1 && goto:next || goto:fail
:: < -----BEGIN 2L.bin----- G1sxRhtbMEobWzFGG1swSg0K -----END 2L.bin----- > ::
- Obs.: Content that is decoded in Base64 in this bat/cmd results in the file "
%temp%\2l.bin
":
To clear/remove command histories typed in line(s) of Doskey
buffers/history, and thus preventing them from appearing when pressed keys ⇧, ⇩, F1, F3, F7, F9 and so on. , you can use a @It Wasn’t Me in this reply, where Doskey is reinstalled and a value of 0 to 50 is reserved, thus erasing the content previously stored in the transitory memories of Doskey
.
for %%i in (reinstall,"listsize=0","listsize=50")do doskey.exe /%%~i
Some additional readings:
[√] Doskey
[√] Findstr
[√] Goto :Label
[√] Escape Characters
[√] Ansi Escape Codes
[√] Conditional Execution || && ...
[√] Base64 Encode or Decode (Macos/Windows/Linux)