2014-10-08 31 views
0

我需要這個文件給你3次嘗試輸入密碼,如果沒有則關機或任何方式關閉第一個失敗的嘗試後60秒 請幫助試圖以批處理文件不工作密碼輸入

這裏是批處理文件

@echo off 
color 02 
set /a %tries%== 4 
set /p %password%== Mike.1587 
taskkill /f /IM explorer.exe 
shutdown -s -t 60000 
goto MAIN-LAUNCH 

:MAIN-LAUNCH 
cls 
if %tries%==0 goto DEATH-OVERRIDE-SHUTDOWN 
title Locked by %username% 
echo Enter Password Before Time Runs Out... 
echo You have %tries% tries left 
set /p password= 
if %password%==Mike.1587 goto IF-TRUE 
if not /p password=Mike.1587 goto NOT-TRUE 


:NOT-TRUE 
%tries% -1 
echo Incorrect Password Try Again... 
echo You have %tries% left 
echo Press any key to try again. . . 
pathping localhost -q 2 -p 3500> nul 
goto MAIN-LAUNCH 


:IF-TRUE 
echo Correct! 
start explorer.exe 
shutdown -a 
pathping localhost -q 2 -p 1000> nul 
exit 

DEATH-OVERRIDE-SHUTDOWN 
shutdown.exe /s /t 00 
exit 
+0

'如果不是/ P密碼= Mike.1587轉到NOT-TRUE''這個/ p'是不是從'if'語法.Probably從'設置/ p'一個複製粘貼?並且需要double = – npocmaka 2014-10-08 21:33:54

+1

不要使用==作爲賦值,所有的ypur標籤前面加上:,使用set/a進行計算是希望cmd知道ypu用%嘗試%-1的含義,不要使用copy&粘貼不看,... – ths 2014-10-08 21:35:37

+1

哦,另外一個:'set/a%tries%== 4'應該是'set tries = 4'等等。真的,這有太多的錯誤,如果你從學習開始編寫批處理腳本。 – ths 2014-10-08 22:00:46

回答

0

這應該做你想做的。很多批處理語法不正確。我建議你在開始下一個項目之前先去網上學習一個基本的教程。

@echo off 
color 02 
set /a tries=3 
set /p P=Mike.1587 
taskkill /f /IM explorer.exe 
shutdown -s -t 60000 

:: Start 
:Attempt 
cls 
if "%tries%"=="0" goto Fail 
title Locked by %username% 
echo Enter Password Before Time Runs Out... 
echo You have %tries% tries left 
set /p "password=Password: " 
if "%password%"=="%P%" goto Correct 

:: Wrong Password 
set /a tries-=1 
echo Incorrect Password Try Again... 
echo You have %tries% left 
echo Press any key to try again. . . 
pathping localhost -q 2 -p 3500> nul 
goto Attempt 

:Correct 
shutdown -a 
echo Correct! 
start explorer.exe 
pathping localhost -q 2 -p 1000> nul 
exit 

:Fail 
shutdown.exe /s /t 00 
exit 
相關問題