cls
@ECHO OFF
title Folder Private
if EXIST "hide" goto UNLOCK
if NOT EXIST Private goto MDLOCKER
if not exist "%temp%\tmppwd.lck" goto setpassword
:setpassword
set/p "passwd=設定密碼:"
echo %passwd% > %temp%\tmppwd.lck
goto CONFIRM
:CONFIRM
echo 是否將資料夾上鎖
set/p "cho=(Y/N)"
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 "hide"
attrib +h +s "hide"
echo Folder locked
goto End
:UNLOCK
for /f %%i in ('type "%temp%\tmppwd.lck"') do set test=%%i
set/p "attempt=請輸入密碼:"
if not "%attempt%"=="%test%" (
goto FAIL
attrib -h -s "hide"
ren "hide" Private
echo 密碼正確
pause
:FAIL
echo 密碼錯誤
goto again
:again
echo 請重新輸入
goto UNLOCK
:MDLOCKER
md Private
echo Private created successfully
goto End
:End