Need help with my code string! Please!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
CoderBAtchie
Posts: 1
Joined: 07 Dec 2016 22:18

Need help with my code string! Please!

#1 Post by CoderBAtchie » 07 Dec 2016 22:21

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
Last edited by aGerman on 08 Dec 2016 00:55, edited 1 time in total.
Reason: code tags added

Cornbeetle
Posts: 31
Joined: 23 Nov 2015 09:34

Re: Need help with my code string! Please!

#2 Post by Cornbeetle » 09 Dec 2016 09:59

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

Post Reply