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

Author Topic: How to run a .bat from another .bat + waiting time between?  (Read 4138 times)

0 Members and 1 Guest are viewing this topic.

karlosss

    Topic Starter


    Beginner

    • Experience: Beginner
    • OS: Windows XP
    For example i have 2 .bats: a.bat and b.bat

    When i click on a.bat i want him to wait two minutes and then automatically start the b.bat, is possible this? thank you!



    karlosss

      Topic Starter


      Beginner

      • Experience: Beginner
      • OS: Windows XP
      Re: How to run a .bat from another .bat + waiting time between?
      « Reply #1 on: May 14, 2017, 08:50:13 AM »
      anyone ?

      patio

      • Moderator


      • Genius
      • Maud' Dib
      • Thanked: 1769
        • Yes
      • Experience: Beginner
      • OS: Windows 7
      Re: How to run a .bat from another .bat + waiting time between?
      « Reply #2 on: May 14, 2017, 08:56:43 AM »
      No need to bump your Posts...if someone can assist they will...
      " Anyone who goes to a psychiatrist should have his head examined. "

      karlosss

        Topic Starter


        Beginner

        • Experience: Beginner
        • OS: Windows XP
        Re: How to run a .bat from another .bat + waiting time between?
        « Reply #3 on: May 14, 2017, 09:01:20 AM »
        ok i apologies

        Geek-9pm


          Mastermind
        • Geek After Dark
        • Thanked: 1026
          • Gekk9pm bnlog
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 10
        Re: How to run a .bat from another .bat + waiting time between?
        « Reply #4 on: May 14, 2017, 09:20:51 AM »
        You can use the sleep command. It was not an official MS-DOS thing.  It is found in Windows 7. And there are third party versions.
        https://www.windows-commandline.com/sleep-command-windows-7/
        Or look at this:
        https://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx



        Salmon Trout

        • Guest
        Re: How to run a .bat from another .bat + waiting time between?
        « Reply #5 on: May 14, 2017, 09:42:49 AM »
        Wait 2 minutes (120,000 milliseconds), no 3rd party stuff required:

        PING 1.1.1.1 -n 1 -w 120000 >NUL

        Batch example:

        Code: [Select]
        @echo off
        echo %date% %time% start
        PING 1.1.1.1 -n 1 -w 120000 >NUL
        echo %date% %time% end

        Script output:

        Code: [Select]
        14/05/2017 16:35:55.80 start
        14/05/2017 16:37:55.31 end

        You can change the number of milliseconds to fine tune it for your machine

        Geek-9pm


          Mastermind
        • Geek After Dark
        • Thanked: 1026
          • Gekk9pm bnlog
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 10
        Re: How to run a .bat from another .bat + waiting time between?
        « Reply #6 on: May 14, 2017, 01:02:25 PM »
        More about delay inside a batch file....
        https://www.computerhope.com/issues/ch001678.htm
        How to create a delay in a batch file
        Updated: 04/26/2017 by Computer Hope
        Quote
        Below is an example of how to delay a batch file. Because there is no delay or sleep option included with MS-DOS or any version of Windows we are using the choice command to trick the batch file into delaying.

        Salmon Trout

        • Guest
        Re: How to run a .bat from another .bat + waiting time between?
        « Reply #7 on: May 14, 2017, 01:17:23 PM »
        we are using the choice command to trick the batch file into delaying.
        I agree that's more elegant than ping, but it;s not available in Windows NT 4, 2000 and XP except from a reskit.

        Geek-9pm


          Mastermind
        • Geek After Dark
        • Thanked: 1026
          • Gekk9pm bnlog
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 10
        Re: How to run a .bat from another .bat + waiting time between?
        « Reply #8 on: May 14, 2017, 02:15:22 PM »
        I agree that's more elegant than ping, but it;s not available in Windows NT 4, 2000 and XP except from a reskit.
        Right! It was pulled from NT, Windows 2000 and Windows XP for some undisclosed resewn. At one time I wrote my own version of the SLEEP  program.  It worked for me, but I never did any real testing to see if it messed up anything.
        Doing a time delay in windows has some potential problems. You do not want to shut off other things working in the background. If you grab the hardware timer, you make it unavailable to other things that might need the the hardware timer. Apparently Microsoft resolved such things when thy released  Windows 7. The Windows 7 program CHOICE does not run in XP.
        There is no elegant method in Windows XP that has Microsoft approval. One could use Powershell for a delay, but for many that is overkill.
        For what it is worth, here is a relevant posting about time delay in XP.
        http://stackoverflow.com/questions/1672338/how-to-sleep-for-5-seconds-in-windowss-command-prompt-or-dos
        Somebody noted you can get the choice command from Windows 95 or 98.

        Salmon Trout

        • Guest
        Re: How to run a .bat from another .bat + waiting time between?
        « Reply #9 on: May 14, 2017, 02:42:39 PM »
        Ping is the common, traditional batch method. I don't really know why I said it wasn't 'elegant'; it's just a line of code. Scripting is not literature.

        Bunch of choices here, including Wscript:

        http://www.robvanderwoude.com/wait.php






        « Last Edit: May 14, 2017, 02:57:05 PM by Salmon Trout »