2011-10-16 36 views
0

我想我的腳本比較用戶輸入和文本從txt文件(例如test.txt) 我知道我可以使用type test.txt,但我不知道如何將其與用戶輸入進行比較.. 你能幫我嗎?謝謝... 這是我有:Txt文件密碼檢查批次

set choice= 
set /p choice=Zvol si heslo slozky: 
+1

該文本文件包含什麼內容?一條線?多行?他們都必須匹配還是隻有一行? – Anders

+0

@Anders單行..對不起.. –

回答

3

你可以做的是寫答案的(臨時)文件,並比較文件。例如:

... 
echo %choice% > tempfile.txt 
fc tempfile.txt test.txt > NUL 
if errorlevel 1 echo answer is different as text.txt 
+0

Thx男人......這就夠了非常感謝 –

0

會詢問是否發現輸入密碼猜測,將輸出到results.txt

@echo off 
echo Password comparer 
set choice= 
set /p choice=Enter your password guess: 

TYPE test.txt | findstr /m %choice% > results.txt