Page 1 of 1

How to make multiple variable acceptable while whitelisting any other variable?

Posted: 12 Sep 2017 19:57
by ZolarKeth
I'm not very good at batch, and I'm trying to create this fake "hacker" so my friends and I can roleplay "nerdy I know lolz :lol: "
Anyways, here's the code if you need it.


@echo off

echo . . .
PING 1.1.1.1 -n 1 -w 2000 >NUL
goto Startup

:Startup
cls
echo Verifying User... input registered account credentials.
set /p Credentials=

if %Credentials%==VK11Cyanide06 goto Correct
if %Credentials%==QX19Trojan87 goto Cracked
if %Credentials% NOT==VK11Cyanide06 OR QX19Trojan87 goto Incorrect

I want VK11Cyanide06 and QX19Trojan87 to be acceptable variables and all other variables to goto "Incorrect". Can anyone tell me how to accomplish this?

Re: How to make multiple variable acceptable while whitelisting any other variable?

Posted: 13 Sep 2017 03:07
by ShadowThief
Just remove the

Code: Select all

if %Credentials% NOT==VK11Cyanide06 OR QX19Trojan87
part of the last line. Batch scripts are read top-down, so once the first two if statements are passed and ignored, everything else will automatically go to Incorrect.

Re: How to make multiple variable acceptable while whitelisting any other variable?

Posted: 13 Sep 2017 04:10
by elzooilogico
Whenever you must evaluate two variables to boolean logic between them

Code: Select all

@echo off
setlocal

set /p var1="Val1, enter true or false: "
set /p var2="Val2, enter true or false: "

rem test AND
if "%var1%"=="true" if "%var2%"=="true" (
  echo/&echo/Both are true & goto :done
)

rem test NOT logic
if not "%var1%"=="true" if not "%var2%"=="true" (
  echo/&echo/None are true & goto :done
)

rem else OR
echo/&echo/One is true
:done
endlocal
exit/B