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

Author Topic: Wait for command to complete before contining batch file  (Read 68567 times)

0 Members and 1 Guest are viewing this topic.

nigelben

    Topic Starter


    Starter

    Wait for command to complete before contining batch file
    « on: March 06, 2009, 10:33:03 AM »
    I have created a batch file with the following syntax

    call  c:\maxl\batch\inflation.bat

    @echo off

    :begin
    febootimail -FROM [email protected] -TO [email protected] -MSG "Inflation Cubes are complete. Please do not respond to this message as it is sent from an unmonitored account." -SUBJECT "Inflation Cubes complete"  -SMTP THCNOTES

    if not errorlevel 5 goto end
    echo Couldn't connect to server. Trying again...
    goto begin

    :end
    echo End of batch program.

    the first line calls another batch file which runs an essbase maxl script in a dos window, the problem is that when it runs the script it calls the 2nd batch file and that closes as soon as it has called the maxl script, I need a way to make the called batch file wait until the maxl script has run its course , is there anyway to make it wait until the script has run

    DaveLembke



      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Wait for command to complete before contining batch file
    « Reply #1 on: March 06, 2009, 12:21:37 PM »
    If you know how long it takes for that process to complete you can use a number of ways to make it count x number of seconds before continuing.

    Would a preset time delay work for you?

    nigelben

      Topic Starter


      Starter

      Re: Wait for command to complete before contining batch file
      « Reply #2 on: March 06, 2009, 12:30:41 PM »
      not really, I need to know the time it is complete and then an email sent, the process could take 30 minutes to an hour based on server usage

      Reno



        Hopeful
      • Thanked: 32
        Re: Wait for command to complete before contining batch file
        « Reply #3 on: March 06, 2009, 10:56:09 PM »
        i tested the following code, and call statement  does calling another batch, and return to the caller once finished.
        Code: [Select]
        @echo off
        (
        echo echo inflation bat start
        echo ping 127.0.0.1 ^>nul
        echo echo inflation bat finish
        )>#.bat

        call #.bat
        echo return from call statement

        so i suspect "inflation.bat" contain some command that run windows program in its own thread/process. or it might contain nt dos command such as "start","%comspec%", or "cmd" which create a new instance.

        GuruGary



          Adviser
          Re: Wait for command to complete before contining batch file
          « Reply #4 on: March 08, 2009, 10:22:53 PM »
          How about changing your CALL batch file command to:

          Code: [Select]
          start /wait cmd /C "c:\maxl\batch\inflation.bat"

          nigelben

            Topic Starter


            Starter

            Re: Wait for command to complete before contining batch file
            « Reply #5 on: March 09, 2009, 09:16:56 AM »
            @echo off
            (
            echo echo inflation bat start
            echo ping 127.0.0.1 ^>nul
            echo echo inflation bat finish
            )>#.bat

            call #.bat
            echo return from call statement

            this command is rewriting the inflation.bat file to read

            echo echo inflation bat start
            echo ping 127.0.0.1 ^>nul
            echo echo inflation bat finish

            Reno



              Hopeful
            • Thanked: 32
              Re: Wait for command to complete before contining batch file
              « Reply #6 on: March 09, 2009, 09:40:12 AM »
              this command is rewriting the inflation.bat file to read

               ??? ??? ???

              it's just an example to proof that call statement does wait for a batch file to finish executing before returning.
              if you can post the code of inflation.bat, maybe someone can help you.

              GuruGary



                Adviser
                Re: Wait for command to complete before contining batch file
                « Reply #7 on: March 09, 2009, 11:52:09 AM »
                I think the code in Reply #4 should work for any code in the "inflation.bat" file.