Options

Set command issue

kenny504kenny504 Users Awaiting Email Confirmation Posts: 237 ■■□□□□□□□□
I am using a batch script that uses the set /p Input= command which requires a user to input text, however i have an issue.

The bacth file itself is working but if a user decides not to input any characters and just press ENTER i would like for the script to move to the next prompt. Instead it just closes, how can i achieve this,

below is a sample of the script.

set /p UsrName=
echo.
if %UsrName% equ User goto Passcode else goto Unauth
:Unauth
cls
color fc
echo.
echo.
echo.
echo.
echo.
echo.
echo. You have entered an Invalid Username, This script has aborted.
echo.
echo.
echo.
echo.
echo.
echo.
pause
exit
:Passcode
echo Username Accepted!!
echo. ================Enter Passcode=================
set /p hexfield=
cls
if %hexfield% equ codes goto starter else goto Invalhex
echo. Passcode Accepted!!
There is no better than adversity, every defeat, every loss, every heartbreak contains its seed. Its own lesson on how to improve on your performance the next time.

Comments

  • Options
    ClaymooreClaymoore Member Posts: 1,637
    I think you have to use multiple nested if statements with a $null value.

    if %UsrName% equ User goto Passcode else if %UsrName% equ $null goto Unauth else goto Unauth

    You may need to use double quotes "" instead of $null, I may be confusing my scripting languages.
Sign In or Register to comment.