Page 1 of 1

Batch to display Happy Birthday

Posted: 27 Sep 2020 08:32
by Hooby1
I have a logon script that maps the user to drives after they logon. Is It possible to show a line within this to say Happy Birthday on the day it is their birthday? Subsequently I can then edit it for other days like Christmas, Easter or other days of interest?

Re: Batch to display Happy Birthday

Posted: 28 Sep 2020 10:47
by aGerman
No problem for holidays or anniversaries at a fixed date.

Code: Select all

@echo off &setlocal
for /f %%i in ('WMIC OS Get LocalDateTime /value') do for /f %%j in ("%%i") do set "%%j"

if "%LocalDateTime:~4,4%"=="0928" echo Happy Today!
if "%LocalDateTime:~4,4%"=="1225" echo Merry Christmas!

pause
But for days like Easter? I never tried to write a transcription of Gauss' Easter algorithm in pure Batch, but you may give it a go ... The formula is large but probably simple enough to bring it into a subroutine.

Steffen

Re: Batch to display Happy Birthday

Posted: 29 Sep 2020 03:01
by Hooby1
Hi Steffen

Many thanks for the quick reply.

This is exactly what I am after, thank you so much.

It is only going to be used to days that stay the same so no problem there.

Thanks again!

Re: Batch to display Happy Birthday

Posted: 29 Sep 2020 11:20
by aGerman
I didnt find an Easter algorithm here, so I decided to write one. Just in case you're interested ...
viewtopic.php?f=3&t=9792#p62989

Steffen