iT邦幫忙

0

想做一個密碼鎖 請幫幫忙看問題出在哪

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
蟹老闆 iT邦大師 1 級 ‧ 2018-12-11 11:46:47 檢舉
if not "%attempt%"=="%test%" (
goto FAIL
更換成
if not "%attempt%"=="%test%" goto FAIL

尚未有邦友回答

立即登入回答