简体   繁体   中英

How to use the call command to validate a password in batch

So I have this code

@echo off  
set /p pass=Input Pass:  
call rig.txt   
if %pass%==rig.txt goto right  
goto wrong  
:wrong  
echo Authentication Failed!  
pause  
exit  
:right  
echo correct  
pause  

So instead of having something like this

@echo off  
set /p pass=Input Pass:  
if %pass%==randompassword goto right  
goto wrong  
:wrong  
echo Authentication Failed!  
pause  
exit  
:right  
echo correct  
pause 

Im trying to get it so it calls rig.txt which has my password in it and checks if i inputed the right password. Please help!

@echo off  

rem Read right password saved in rig.txt file
set /P rightPass=< rig.txt

set /p pass=Input Pass:  
if %pass% == %rightPass% goto right  
echo Authentication Failed!  
pause  
exit  

:right  
echo correct  
pause 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM