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

Author Topic: time  (Read 19194 times)

0 Members and 1 Guest are viewing this topic.

greg



    Intermediate

    Thanked: 7
    Re: time
    « Reply #30 on: April 01, 2010, 11:19:34 AM »
    No need for a script file. You can run from the command prompt:

    mshta vbscript:(MsgBox(DateAdd("n",1,Now)))


    How do we save the output of
    b]mshta vbscript:(MsgBox(DateAdd("n",1,Now)))[/b]
    to a batch variable?  Matt, the original poster, ask that the output be assigned to
    batch variable.

    C:\batch>time /t
    12:15 PM

    C:\batch>mshta vbscript:(MsgBox(DateAdd("n",1,Now)))

    C:\batch>



    [recovering disk space - old attachment deleted by admin]
    « Last Edit: April 01, 2010, 11:30:41 AM by greg »
    Have a Nice Day

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: time
    « Reply #31 on: April 01, 2010, 03:19:07 PM »
    Normally I try not to get involved with all the shenanigans that seem to go on, but sometimes these threads get turned around into Greg's questions and the OP seems forgotten.

    Quote
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    d:\batch>WScript.Echo DateAdd("n",1,Now)

    I posted the mshta one-liner in response to Geek-9PM. It was merely to demonstrate how to run VBScript instructions from the command prompt.

    How do we save the output of
    mshta vbscript:(MsgBox(DateAdd("n",1,Now)))
    to a batch variable?  Matt, the original poster, ask that the output be assigned to
    batch variable.

    I thought you had given the definitive answer with your batch solution Greg. Far be it from me to steal your thunder. I'll leave the OP in your capable hands to answer the age old question "How do we save the output of mshta vbscript:(MsgBox(DateAdd("n",1,Now))) to a batch variable? I'm actually looking forward to the answer myself.

    Good luck. 8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    Helpmeh



      Guru

    • Roar.
    • Thanked: 123
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 8
    Re: time
    « Reply #32 on: April 01, 2010, 04:29:07 PM »
    I'm actually looking forward to the answer myself.

    Good luck. 8)
    for /f "delims=" %%a in ('mshta vbscript:(MsgBox(DateAdd("n",1,Now)))') do set newtime=%%a

    Now, I got a really strong feeling that that won't work...
    Where's MagicSpeed?
    Quote from: 'matt'
    He's playing a game called IRL. Great graphics, *censored* gameplay.

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: time
    « Reply #33 on: April 01, 2010, 04:47:07 PM »
    for /f "delims=" %%a in ('mshta vbscript:(MsgBox(DateAdd("n",1,Now)))') do set newtime=%%a

    Now, I got a really strong feeling that that won't work...

    Nope. the issue here is that mshta doesn't use the console, certainly not if you use Msgbox. In order to get mshta to output to the console, one would need to write a COM component that attaches to the console and outputs a string to it, create it with CreateObject() and call that method with the calculation. All a bit too much work for what is necessary in this circumstance.
    I was trying to dereference Null Pointers before it was cool.

    greg



      Intermediate

      Thanked: 7
      Re: time
      « Reply #34 on: April 01, 2010, 04:58:29 PM »

      I posted the mshta one-liner in response to Geek-9PM. It was merely to demonstrate how to run VBScript instructions from the command prompt.

      "How do we save the output of mshta vbscript:(MsgBox(DateAdd("n",1,Now))) to a batch variable? I'm actually looking forward to the answer myself.

      I don't know  the answer and I don't know how to find it. I have never used VBS.

      mshta vbscript:(MsgBox(DateAdd("n",1,Now)))  works very well much better than the batch file.

      It  also works without MsgBox().

      mshta vbscript:(DateAdd("n",1,Now)) works but I cannot assign the output to a variable nor redirect the output.

      Thanks  for your help.


      I suspect you have already furnished the OP with the answer he needs.

      Have a Nice Day

      mat123

        Topic Starter


        Hopeful

        Thanked: 16
        • Yes
        • Yes
        • Yes
      • Experience: Familiar
      • OS: Windows XP
      Re: time
      « Reply #35 on: April 01, 2010, 06:02:31 PM »
      greg your batch solution worked



      Salmon Trout

      • Guest
      Re: time
      « Reply #36 on: April 02, 2010, 04:03:06 AM »
      your thunder

      Damp firecracker more like.

      greg



        Intermediate

        Thanked: 7
        Re: time
        « Reply #37 on: April 02, 2010, 01:14:27 PM »
        Damper.


        Matt wrote:

        "Greg, your batch solution worked."
        Have a Nice Day

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: time
        « Reply #38 on: April 02, 2010, 01:37:44 PM »
        Matt wrote:

        "Greg, your batch solution worked."

        Very good!

        Do you remember how many sides a Triangle has too?
        I was trying to dereference Null Pointers before it was cool.

        greg



          Intermediate

          Thanked: 7
          Re: time
          « Reply #39 on: April 02, 2010, 02:04:56 PM »
          Very good!

          Do you remember how many sides a Triangle has too?

          A Triangle has four sides and 360 degrees.
          Have a Nice Day

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: time
          « Reply #40 on: April 02, 2010, 02:08:39 PM »
          A Triangle has four side and 360 degrees.

          I certainly hope that is a attempt at humour.
          I was trying to dereference Null Pointers before it was cool.

          greg



            Intermediate

            Thanked: 7
            Re: time
            « Reply #41 on: April 02, 2010, 02:15:11 PM »
            I certainly hope that is a attempt at humour.

            A Triangle has four sides and 360 degrees.

            Those are facts.

            But back on topic:

            mshta vbscript:(DateAdd("n",1,Now)) works but I cannot assign the output to a variable nor redirect the output.




            Have a Nice Day

            Salmon Trout

            • Guest
            Re: time
            « Reply #42 on: April 02, 2010, 02:27:37 PM »
            A Triangle has four sides and 360 degrees.

            Those are facts.


            Greg, the Pythagoras de nos jours.


            greg



              Intermediate

              Thanked: 7
              Re: time
              « Reply #43 on: April 02, 2010, 06:59:09 PM »
              How can I add one minute to the current time and store it as a variable.

              Here is another solution. Half VBS and half batch.
              BC_programmer wrote the VBS half.


              C:\batch>type bc4.bat
              Code: [Select]
              @echo off
              rem bc4.vbs written by BC_programmer
              rem curDate=Now
              rem WScript.echo "Current Date:" + Cstr(curDate)
              rem newDate = dateAdd("n",1,Now)
              rem WScript.echo "Date plus 1 minute"  + Cstr(newdate)

              setlocal enabledelayedexpansion
              for /f "delims=" %%i in ('cscript //nologo bc4.vbs') do (
              rem echo %%i
              set batvar="%%i"
              echo.
              echo batvar=!batvar!
              )

              Output:

              C:\batch>bc4.bat

              batvar="Current Date:4/2/2010 7:51:04 PM"

              batvar="Date plus 1 minute:4/2/2010 7:52:04 PM"

              C:\batch>
              Have a Nice Day

              Carbon Dudeoxide

              • Global Moderator

              • Mastermind
              • Thanked: 169
                • Yes
                • Yes
                • Yes
              • Certifications: List
              • Experience: Guru
              • OS: Mac OS
              Re: time
              « Reply #44 on: April 03, 2010, 05:17:42 AM »
              Greg, a triangle has 3 sides, each vertex adding up to 180 degrees.

              greg your batch solution worked


              I assume the topic can be closed now?