Page 1 of 1

Need help with my code string! Please!

Posted: 07 Dec 2016 22:21
by CoderBAtchie
I am 17 and am very new to batch filing. I have everything setup the way I want it so far except for one thing.. My batch open a cmd prompt windows with a username and password if the username is chosen correctly. However, if someone presses enter with the user box it just sends them straight to the password. Heres the coding.

Code: Select all

color a
@echo off
title RegistryData Beta 1.0 Designed by ________
echo Welcome to Registry 1.0- Beta Designed by _______
echo User access will be permitted if desired user is ___ _______
echo ///////////////////////////////////////////////////////////////////


pause

cls
:Username
Set input=1
set/p input= ID
if "%input%"=="" (
goto N2
)
if %input%==1 goto :Password
if not %input%==1 goto N2

:N2
Echo INCORRECT IDENTIFICATION
Set input=1
set /p input= ID (If Incorrect Access Will Be Denied) :
if %input%==1 goto :Password
if not %input%==1 goto N2.1

:N2.1
Echo WRONG IDENTIFICATION. PROGRAM IS CLOSING
Pause
Exit



:Password
Set input=
set /p input= Password (Access Will Be Denied If Failed 3 Times) :
if %input%==Qazwsx12321 goto YES
if not %input%==Qazwsx12321 goto NO1


:YES

Start Logs.txt
Exit

:NO1

Echo INCORRECT PASSWORD
Set input=
set /p input= Password (input then press enter) :
if %input%==Qazwsx12321 goto YES
if not %input%==Qazwsx12321 goto NO2

:NO2

Echo INCORRECT PASSWORD
Set input=
set /p input= Password (input then press enter) :
if %input%==Qazwsx12321 goto YES
if not %input%==Qazwsx12321 goto NO3

:NO3

Echo INCORRECT PASSWORD
Pause
Echo WINDOW WILL NOW CLOSE
Pause
Exit

Re: Need help with my code string! Please!

Posted: 09 Dec 2016 09:59
by Cornbeetle
Take out the "set input=1" line in this block of code:

:Username
Set input=1
set/p input= ID
if "%input%"=="" (
goto N2


Your pre-setting the input variable, so whenever someone hits enter, the input variable will remain as "1".

It should look like this:

Code: Select all

:Username
set/p input= ID
if "%input%"=="" (
goto N2