I just wrote a simple script cmd to hide private folders by combining several scripts from the Internet. Can anyone give me suggestions for improvement?
This batch file uses a password hidden by powershell script. Then I create a shortcut and run attrib -s -h
, so it is not easy to find.
It works just gave attrib -s -h
on the desired folder. Location folder can only be changed by editing the file. Also passwords can only be changed by editing the batch file. The last two things are quite cumbersome.
@echo off
title Privat Locker
set _folder="E:\Private"
dir /a:h %_folder%>nul 2>nul
if %errorlevel%==0 goto PASS1
dir /a:s %_folder%>nul 2>nul
if %errorlevel%==0 goto PASS1
:CONFIRM
echo Do you want to lock the Private 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 Error! Wrong answer, please type [Y/N]
goto CONFIRM
:LOCK
attrib +h +s %_folder%
echo The folder sucsessfully locked...
pause
goto end
:PASS1
set "psCommand=powershell -Command "$pword = read-host 'Masukkan PIN!' -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
if NOT "%password%"=="YOURPINHERE" goto FAIL1
attrib -s -h %_folder%
goto EXP
:PASS2
set "psCommand=powershell -Command "$pword = read-host 'Masukkan PIN!' -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
if NOT "%password%"=="YOURPINHERE" goto FAIL2
attrib -s -h %_folder%
goto EXP
:PASS3
set "psCommand=powershell -Command "$pword = read-host 'Masukkan PIN!' -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
if NOT "%password%"=="YOURPINHERE" goto FAIL3
attrib -s -h %_folder%
:EXP
echo Folder successfully unlocked, do you want to look it? [Y/N]
set/p "tuju=>"
if %tuju%==Y goto BUKA
if %tuju%==y goto BUKA
if %tuju%==n goto end
if %tuju%==N goto end
echo Error! Pilihan salah, ketik [Y/N]
goto EXP
:BUKA
echo Go to folder...
pause
start explorer %_folder%
goto end
:FAIL1
echo Wrong PIN!
echo Try again, 2 remaining
goto PASS2
:FAIL2
echo Wrong PIN!
echo Try again! 1 remaining
goto PASS3
:FAIL3
echo Wrong PIN!
echo Device will reboot!
:PIL
set/p "rst=Automatic Restart? [Y/N]"
if %rst%==Y goto RST
if %rst%==y goto RST
if %rst%==N goto MNL
if %rst%==n goto MNL
echo Error! wrong choice, pleas type [Y/N]
goto PIL
:RST
shutdown -r -t 15 -c "Computer will reboot on 15 second's"
pause
goto end
:MNL
echo If device not rebooting on 15 minutes, all data[s] in the folder
echo will be erased...
pause
:end