Script with IF (time) less than

Asked

Viewed 94 times

1

Good afternoon, I am behind a command (cmd/batch) to execute a command with a condition.

Ex: Checking the user name

 SET var=%username%
    IF "%var%"=="Carlos" (msg Carlos 'usuario confirmado')

    pause

I would like another to check also the time, to be shown to msg good morning, good afternoon, good night.

If you can help me... I appreciate it now

  • https://stackoverflow.com/questions/tagged/batch-file

1 answer

1


 SET var= "Digite o usuário"
    IF %var%=="Carlos" Goto MSG

:MSG
 Echo "Carlos usuario confirmado"
    pause

And for the date test it:

echo %time:~0,2%

if %time:~0,2%  LEQ 12 goto manha
if %time:~0,2%  LEQ 18 goto tarde
if %time:~0,2%  LEQ 24 goto noite

:manha
    echo "manha"
    Pause

:tarde
    echo "tarde"
    Pause

:noite
    echo "noite"
    Pause
  • That’s it. It worked?

  • Thank you very much!

  • yes ;) that’s what I wanted

  • Not wanting to abuse, but how would I include time for dawn? EX: from 00:00 till 06:00?

  • puts another if

  • if %time:~0,2% LEQ 6 goto dawn

  • Vlw! Thank you for your attention!

  • If you can take a look here: https://answall.com/questions/332063/inser-vari%C3%A1vel-em-script

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.