Insert variable in script

0

I have the following script working normally

@echo off

if %time:~0,8%  LEQ 11:59:59 goto manha
if %time:~0,8%  LEQ 17:59:59 goto tarde
if %time:~0,8%  LEQ 23:59:59 goto noite

:manha
    echo "BOM DIA"
    Pause

:tarde
    echo "BOA TARDE"
    Pause

:noite
    echo "BOA NOITE"
    Pause

I would like to insert a variable to be able to use in other lines, Example of the code below that did not work:

@echo off

if %time:~0,8%  LEQ 11:59:59 goto manha
if %time:~0,8%  LEQ 17:59:59 goto tarde
if %time:~0,8%  LEQ 23:59:59 goto noite



:manha
    set saudacao= "BOM DIA"


:tarde
    set saudacao= "BOA TARDE"


:noite
    set saudacao= "BOA NOITE"


echo %saudacao% , Resto da frase
pause

Does anyone know what I'm missing? Thank you in advance!

    
asked by anonymous 25.09.2018 / 15:26

1 answer

1

Friend, this second script is missing the goto after every sentence:

Example:

@echo off

if %time:~0,8%  LEQ 11:59:59 goto manha
if %time:~0,8%  LEQ 17:59:59 goto tarde
if %time:~0,8%  LEQ 23:59:59 goto noite

:manha
    set saudacao= "BOM DIA"
    goto fim


:tarde
    set saudacao= "BOA TARDE"
    goto fim
:noite
    set saudacao= "BOA NOITE"
    goto fim
:fim
   echo %saudacao% , Resto da frase
   pause
    
25.09.2018 / 15:33