jeudi 17 septembre 2020

If statement in batch file - user chooses option

New to batch/sql files. Thanks for you help.

What im trying to do:

  • user picks option 1, runs my sql file.
  • user picks 2, exits program.
  • user enters nothing or invalid option, ECHO "invalid option".

Problem: anything I type will exit my program. What am I doing wrong?

ECHO 1 - Show Report
ECHO 2 - Exit

SET choice=""
SET /P input=Your choice: 
IF "%input%"=="1" (
    GOTO :sql file
) ELSE (
    IF "%input%"=="2" (
    GOTO :Exit
    )
) ELSE (
    IF "%input%"=="" (
    ECHO Invalid option chosen.
    )
)
PAUSE

Aucun commentaire:

Enregistrer un commentaire