Bat file not running commands

Eduardo Martínez 20 Reputation points
2023-07-04T02:41:59.23+00:00

I started experimenting with bat files, I created the file below, but is not running as expected:

@ECHO off
cls
:Start
ECHO 1. SFC
ECHO 2. CheckHealth
ECHO 3. ScanHealth
ECHO 4. RestoreHealth
ECHO 5. Exit
Set choice=
Set /p choice=Selecciona la opción: 
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto SFC
if '%choice%'=='2' goto CheckHealth
if '%choice%'=='3' goto ScanHealth
if '%choice%'=='4' goto RestoreHealth
if '%choice%'=='5' goto end
ECHO "%choice%" No es una opción válida
ECHO.
goto Start
:CheckHealth
ECHO DISM /Online /Cleanup-Image /CheckHealth
goto Start
:ScanHealth
ECHO DISM /Online /Cleanup-Image /ScanHealth
goto Start
:SFC
ECHO SFC /scannow
goto Start
:RestoreHealth
ECHO DISM /Online /Cleanup-Image /RestoreHealth
goto Start
:end

The commands are not running I just see, for example, SFC /scannow but does nothing, it takes me back to the menu.

User's image

I think the solution should be very easy but a newbie in bat files.

Thanks for your help.

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. Olaf Helper 47,581 Reputation points
    2023-07-04T05:39:08.5233333+00:00

    but does nothing, it takes me back to the menu.

    Of course, you added on each line a ECHO command; an echo prints only the command, but don't execute it; see

    https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/echo

    Remove the echo.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Eduardo Martínez 20 Reputation points
    2023-07-04T05:47:20.1766667+00:00

    Thank you!!

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.