Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Good morning / Good afternoon display in BAT  (Read 10237 times)

0 Members and 1 Guest are viewing this topic.

TheHoFL

    Topic Starter


    Intermediate

    Thanked: 5
    Good morning / Good afternoon display in BAT
    « 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
    All your dreams can come true if you have the courage to pursue them.  - Walt Disney

    Helpmeh



      Guru

    • Roar.
    • Thanked: 123
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 8
    Re: Good morning / Good afternoon display in BAT
    « Reply #1 on: May 28, 2009, 04:49:40 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!)
    « Last Edit: May 28, 2009, 05:00:38 PM by Helpmeh »
    Where's MagicSpeed?
    Quote from: 'matt'
    He's playing a game called IRL. Great graphics, *censored* gameplay.

    TheHoFL

      Topic Starter


      Intermediate

      Thanked: 5
      Re: Good morning / Good afternoon display in BAT
      « Reply #2 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?
      All your dreams can come true if you have the courage to pursue them.  - Walt Disney

      Helpmeh



        Guru

      • Roar.
      • Thanked: 123
        • Yes
        • Yes
      • Computer: Specs
      • Experience: Familiar
      • OS: Windows 8
      Re: Good morning / Good afternoon display in BAT
      « Reply #3 on: May 28, 2009, 04:59:23 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.
      Where's MagicSpeed?
      Quote from: 'matt'
      He's playing a game called IRL. Great graphics, *censored* gameplay.

      TheHoFL

        Topic Starter


        Intermediate

        Thanked: 5
        Re: Good morning / Good afternoon display in BAT
        « Reply #4 on: May 28, 2009, 05:01:41 PM »
        Works like a charm! Thank you for your assistance! You are very much appreciated right now!  ;D

        -HoFL
        All your dreams can come true if you have the courage to pursue them.  - Walt Disney

        Helpmeh



          Guru

        • Roar.
        • Thanked: 123
          • Yes
          • Yes
        • Computer: Specs
        • Experience: Familiar
        • OS: Windows 8
        Re: Good morning / Good afternoon display in BAT
        « Reply #5 on: May 28, 2009, 05:02:35 PM »
        Works like a charm! Thank you for your assistance! You are very much appreciated right now!  ;D

        -HoFL
        No problem! Feel free to stick around and help out other members, or get help if you need it!
        Where's MagicSpeed?
        Quote from: 'matt'
        He's playing a game called IRL. Great graphics, *censored* gameplay.

        TheHoFL

          Topic Starter


          Intermediate

          Thanked: 5
          Re: Good morning / Good afternoon display in BAT
          « Reply #6 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.  ;D
          All your dreams can come true if you have the courage to pursue them.  - Walt Disney

          Helpmeh



            Guru

          • Roar.
          • Thanked: 123
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Familiar
          • OS: Windows 8
          Re: Good morning / Good afternoon display in BAT
          « Reply #7 on: May 28, 2009, 05:06:45 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.  ;D
          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!
          Where's MagicSpeed?
          Quote from: 'matt'
          He's playing a game called IRL. Great graphics, *censored* gameplay.

          TheHoFL

            Topic Starter


            Intermediate

            Thanked: 5
            Re: Good morning / Good afternoon display in BAT
            « Reply #8 on: May 28, 2009, 05:11:02 PM »
            Check this out, you will find it awesome!  :D ...

            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
            All your dreams can come true if you have the courage to pursue them.  - Walt Disney

            Fairadir



              Rookie

              Thanked: 1
              Re: Good morning / Good afternoon display in BAT
              « Reply #9 on: May 28, 2009, 05:16:44 PM »
              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.

              Helpmeh



                Guru

              • Roar.
              • Thanked: 123
                • Yes
                • Yes
              • Computer: Specs
              • Experience: Familiar
              • OS: Windows 8
              Re: Good morning / Good afternoon display in BAT
              « Reply #10 on: May 28, 2009, 05:17:43 PM »
              Check this out, you will find it awesome!  :D ...

              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...
              Where's MagicSpeed?
              Quote from: 'matt'
              He's playing a game called IRL. Great graphics, *censored* gameplay.

              TheHoFL

                Topic Starter


                Intermediate

                Thanked: 5
                Re: Good morning / Good afternoon display in BAT
                « Reply #11 on: May 28, 2009, 05:20:20 PM »
                Hmm... Are you connected to an AD domain? This seems to work for me...

                All your dreams can come true if you have the courage to pursue them.  - Walt Disney

                Helpmeh



                  Guru

                • Roar.
                • Thanked: 123
                  • Yes
                  • Yes
                • Computer: Specs
                • Experience: Familiar
                • OS: Windows 8
                Re: Good morning / Good afternoon display in BAT
                « Reply #12 on: May 28, 2009, 05:22:57 PM »
                Hmm... Are you connected to an AD domain? This seems to work for me...


                To an what?
                Where's MagicSpeed?
                Quote from: 'matt'
                He's playing a game called IRL. Great graphics, *censored* gameplay.

                TheHoFL

                  Topic Starter


                  Intermediate

                  Thanked: 5
                  Re: Good morning / Good afternoon display in BAT
                  « Reply #13 on: May 28, 2009, 05:24:00 PM »
                  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.
                  All your dreams can come true if you have the courage to pursue them.  - Walt Disney

                  TheHoFL

                    Topic Starter


                    Intermediate

                    Thanked: 5
                    Re: Good morning / Good afternoon display in BAT
                    « Reply #14 on: May 28, 2009, 05:26:48 PM »
                    Oh and AD is Active Directory.

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


                    All your dreams can come true if you have the courage to pursue them.  - Walt Disney