0
set "option="
set /p "option= Here=" 

::This is the part that is not working 
if %option% EQU () (goto :MyLabel)
if %option% EQU [] (goto :MyLabel)
IF [%1] == [] GOTO MyLabel

Every time that I write in the batch file it kicks me out with a anexpected error. I am trying to make an script that if the user click enters or space enter. It sends me back to the label. Please help. I have tried with everything on the web but I can find the solution.

I am very new with this.


This is all the code that I have:

@echo off
:mylabel 

@Echo only d .
set "option="
set /p "option= Here=" 
if %option% EQU d (goto :mylabel)
if %option% EQU "" (goto :mylabel)
if "%option%" EQU "" (goto :mylabel)
if "option" EQU "" (goto :mylabel)
IF "%1"=="" GOTO mylabel

-------------
:menu
set "option="
set /p "option= Here="  
if "%option%" EQU "" (goto :menu)
if %option% EQU c (goto :c)
:c
Pang
  • 9,564
  • 146
  • 81
  • 122
kboga
  • 43
  • 6

2 Answers2

0

The problem is going to be with the ( ) chars as they would be unexpected where you are using them (in an empty value). Instead use quotes to do the comparision.

REM It appears some code is missing, so only updating what I can see.

set /p "option=Here:"

REM Check for empty with quotes.
if "%option%" EQU "" goto :MyLabel
IF "%~1" == "" GOTO MyLabel
Jason Faulkner
  • 6,378
  • 2
  • 28
  • 33
0

Solution:

:menu
set "option="
set /p "option= Here=" 
if "%option%" EQU "" (goto :menu)
if %option% EQU c (goto :c)
:c
Pang
  • 9,564
  • 146
  • 81
  • 122
kboga
  • 43
  • 6