Categories
Welcome Center
Education & Development
Cyber Security
Virtualization
General
Certification Preparation
Project Management
Posts
Groups
Training Resources
Infosec
IT & Security Bootcamps
Practice Exams
Security Awareness Training
About Us
Home
General
Off-Topic
Set command issue
kenny504
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!!
Find more posts tagged with
Comments
Claymoore
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.
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of