Batch Script Bug

XylexRayne

Solid State Member
Messages
16
I have the following Batch Script:
@echo off
:start
cls
echo. && set /p MO=Enter the password:
)
if /i "%MO%"=="123123" (
goto Run
)
:invalid
echo Invalid Input
timeout 5
goto start
:run
echo Password Worked
timeout 5
goto start

What should happen is when you login... it runs a program... the restarts so another user may do the same...

My problem is when the script restarts, there is a flaw.
You can press enter and It counts that as a pass.

I am trying to get these done before Wednesday
Thats why I have posted so many issues here....

Ive just gone around the without fixing them, canceling certain plans I had...

This time... There is no way around.. this flaw is my MAJOR hold back...

I am BEGGING for help. T..T

-Xylex
 
if batch has conditional statements or loops i'd do something like

while [variable]== null
{
EnterPassword();
}

or

if [variable] == null

exit(1);

Sorry, I code in c/c++. Those are my suggestions. Hopefully this helps. Not too sure of the batch equivalent.

EDIT: I just thought of something else, sometimes undefined variables do weird and random things. You could do something like

[variable]=0; then set the conditional statement / loop to equal 0 instead. This way if they don't input anything it stays the same. Of course the flaw is, if they enter 0 as the password it won't function properly. You could change it to anything you want, maybe something random or not on the keyboard like Æ’.
 
Back
Top Bottom