1.

Solve : Good morning / Good afternoon display in BAT?

Answer»

Hello,

I am CREATING a logon BAT and i would like to display "Good Morning" or "Good Afternoon" depending on the current time.

I have looked this up for some time now and cannot seem to find a way to make this work in a BAT. I really do not want to use a VBS for this one...

This is what i am looking for:
If a user logs in when the logon.bat executes it will display "Good Morning" if the time is before 12pm and after 12am. Then if the user logs in after 12pm and before 12am, it will display "Good Afternoon".

I am getting frustrated with this on and need assistance. Can anyone assist me with this?

Thank you!

-HoFLQuote from: TheHoFL on May 28, 2009, 04:43:27 PM

Hello,

I am creating a logon BAT and i would like to display "Good Morning" or "Good Afternoon" depending on the current time.

I have looked this up for some time now and cannot seem to find a way to make this work in a BAT. I really do not want to use a VBS for this one...

This is what i am looking for:
If a user logs in when the logon.bat executes it will display "Good Morning" if the time is before 12pm and after 12am. Then if the user logs in after 12pm and before 12am, it will display "Good Afternoon".

I am getting frustrated with this on and need assistance. Can anyone assist me with this?

Thank you!

-HoFL
for /f "delims=:" %A in ("%time%") do if %A LSS 12 (echo Good morning!) else (echo Good afternoon!)I just added this to the beginning of my BAT and it is not working. It simply closes the CMD windows very quickly. I added pause after it, but it will not stay open. Any ideas?Quote from: TheHoFL on May 28, 2009, 04:57:55 PM
I just added this to the beginning of my BAT and it is not working. It simply closes the CMD windows very quickly. I added pause after it, but it will not stay open. Any ideas?
Sorry...add space between "delims=:" and %A

If that doesn't work, run CMD and drag the BATCH file to the window...press enter and see if it displays any messages.Works like a charm! Thank you for your assistance! You are very much appreciated right now!

-HoFLQuote from: TheHoFL on May 28, 2009, 05:01:41 PM
Works like a charm! Thank you for your assistance! You are very much appreciated right now!

-HoFL
No problem! Feel free to stick around and help out other members, or get help if you need it!I am always looking for people to help. I am somewhat new to some of the commands used in BAT files. I pretty much used to make them when i needed them and then stop. I am trying to take the time to learn now though. Quote from: TheHoFL on May 28, 2009, 05:04:47 PM
I am always looking for people to help. I am somewhat new to some of the commands used in BAT files. I pretty much used to make them when i needed them and then stop. I am trying to take the time to learn now though.
That's great! Batch is extremely easy to learn, a bit difficult to master, but is so usefull for organizing files/folders or automating tasks!Check this out, you will find it awesome! ...

Code: [Select]@echo off

for /f "tokens=2*" %%a in ('net user "%Username%" /domain ^| find /i "Full Name"') do SET DisplayName=%%b

for /f "delims=:" %%A in ("%time%") do if %%A LSS 12 (echo Good morning and welcome %DisplayName%) else (echo Good afternoon and welcome %DisplayName%)
echo.
ECHO You are currently signing on to %COMPUTERNAME%
echo.
ECHO Please wait while authenticating %username% with the %USERDOMAIN% domain.
echo.

pause

echo on
Very nice! I SAVED that one in my bat folder.
I really like the idea too.

Thanks for starting this topic, and thanks to Helpmeh for the solution.
Quote from: TheHoFL on May 28, 2009, 05:11:02 PM
Check this out, you will find it awesome! ...

Code: [Select]@echo off

for /f "tokens=2*" %%a in ('net user "%Username%" /domain ^| find /i "Full Name"') do set DisplayName=%%b

for /f "delims=:" %%A in ("%time%") do if %%A LSS 12 (echo Good morning and welcome %DisplayName%) else (echo Good afternoon and welcome %DisplayName%)
echo.
ECHO You are currently signing on to %COMPUTERNAME%
echo.
ECHO Please wait while authenticating %username% with the %USERDOMAIN% domain.
echo.

pause

echo on
Quote
System error 1355 has occurred.

The specified domain either does no exist or could not be contacted.

Good afternoon and welcome

You are currently signed on to COMPUTERNAME

Please wait while authenticating USERNAME with the USERDOMAIN domain.
Note, %userdomain%==%computername% and %computername% NEQ %username%...

Just putting that out there...Hmm... Are you connected to an AD domain? This seems to work for me...

Quote from: TheHoFL on May 28, 2009, 05:20:20 PM
Hmm... Are you connected to an AD domain? This seems to work for me...


To an what?Just ran it right now. This is what i got. I changed the credentials and information, but this is what came up. Because i am joined to a domain the domain is not the PC name... fyi...

Quote
Good afternoon and welcome Michael LASTNAME

You are currently signing on to COMPUTERNAME

Please wait while authenticating username "USERNAME" with the DOMAINNAME domain.
Oh and AD is Active Directory.

fyi...http://en.wikipedia.org/wiki/Active_Directory




Discussion

No Comment Found