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

Author Topic: how to call batch files within a batch file  (Read 7813 times)

0 Members and 1 Guest are viewing this topic.

wlee618

  • Guest
how to call batch files within a batch file
« on: February 18, 2008, 08:21:00 PM »
HI,
i am so stuckwith this... i am trying to call several batch files within a batch file... i have used the 'call batchxxx' it just won't continue.' basically, this is what i am trying to do..

1.call a little '.exe' file
2.then start calling batch file1
3.sleep 20
4.then start calling batch file 2
5.sleep10
.
.
.
.
end
 
can someone help~~~~~~~



devil_himself



    Rookie

    Re: how to call batch files within a batch file
    « Reply #1 on: February 18, 2008, 11:36:07 PM »
    Try This

    Code: [Select]
    @echo off
    call c:\temp\YourExe.exe
    Call C:\Batch1.bat
    ping -n 20 localhost >nul
    Call C:\Batch2.bat
    ping -n 10 localhost >nul

    wlee618

    • Guest
    Re: how to call batch files within a batch file
    « Reply #2 on: February 21, 2008, 04:06:48 PM »
    do i need to have some type of 'end' in the little/sub batch file so it needs to send a 'done with that batch file' back to the main batch file so the main batch file will continue on to the next command? no?

    devil_himself



      Rookie

      Re: how to call batch files within a batch file
      « Reply #3 on: February 22, 2008, 01:17:13 AM »
      Code: [Select]
      @echo off
      call c:\temp\YourExe.exe
      Call C:\Batch1.bat
      Echo Done With Batch1
      ping -n 20 localhost >nul
      Call C:\Batch2.bat
      ping -n 10 localhost >nul

      Computer Hope Admin

      • Administrator


      • Prodigy

        Thanked: 248
        • Yes
        • Yes
        • Yes
        • Computer Hope
      • Certifications: List
      • Computer: Specs
      • Experience: Guru
      • OS: Windows 10
      Re: how to call batch files within a batch file
      « Reply #4 on: February 22, 2008, 04:33:06 AM »
      do i need to have some type of 'end' in the little/sub batch file so it needs to send a 'done with that batch file' back to the main batch file so the main batch file will continue on to the next command? no?
      No. The batch file will not continue with the next line until the batch files that are called are completed.
      Everybody is a genius. But, if you judge a fish by its ability to climb a tree, it will spend its whole life believing that it is stupid.
      -Albert Einstein

      WillyW



        Specialist
      • Thanked: 29
      • Experience: Experienced
      • OS: Windows XP
      Re: how to call batch files within a batch file
      « Reply #5 on: February 22, 2008, 11:45:30 AM »
      HI,
      i am so stuckwith this... i am trying to call several batch files within a batch file... i have used the 'call batchxxx' it just won't continue.' basically, this is what i am trying to do..

      1.call a little '.exe' file
      2.then start calling batch file1
      3.sleep 20
      4.then start calling batch file 2
      5.sleep10
      .
      .
      .
      .
      end
       
      can someone help~~~~~~~





      It looks to me like you do do not want your main batch file to wait for a called batch file to complete its running before proceeding.
      Correct?

      You might like to check out:
      http://www.computerhope.com/starthlp.htm

      If I'm understanding you correctly,  you might wind up with something like:
      Code: [Select]
      @echo off
      cls
      start little_exe_file.exe

      start bat_file_1.bat

      sleep 20

      start bat_file_2.bat

      sleep10

      This assumes that you have a program named   "sleep"  in the same directory as your main batch file,  or in your path.

      Experiment with it, and let us know if this is what you were trying to do.



      .



      gregflowers



        Rookie

        Thanked: 3
        Re: how to call batch files within a batch file
        « Reply #6 on: February 22, 2008, 02:03:47 PM »
        start /wait file1.exe
        start /wait file2.bat
        start /wait file3.com


        This will case the cmd to wait until the called program returns an exit code.