Batch to display Happy Birthday

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Hooby1
Posts: 17
Joined: 27 Sep 2020 08:28

Batch to display Happy Birthday

#1 Post by Hooby1 » 27 Sep 2020 08:32

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?

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Batch to display Happy Birthday

#2 Post by aGerman » 28 Sep 2020 10:47

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

Hooby1
Posts: 17
Joined: 27 Sep 2020 08:28

Re: Batch to display Happy Birthday

#3 Post by Hooby1 » 29 Sep 2020 03:01

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!

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Batch to display Happy Birthday

#4 Post by aGerman » 29 Sep 2020 11:20

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

Post Reply