Categories
Welcome Center
Education & Development
Discussions
Certification Preparation
Recent Posts
Groups
Free Resources
Ebooks
Free Workshops
Trending Certifications Infographic
Infosec Training
IT & Security Training
Live Boot Camps
Security Awareness Training
About Infosec Institute
Home
Discussions
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
Save $250 on 2025 certification boot camps from Infosec!
Book now with code EOY2025
Button
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
INFOSEC Boot Camps
$250
OFF
Use code
EOY2025
to receive $250 off your 2025 certification boot camp!
BROWSE BOOT CAMPS