Batch - Wait for the end of a process

Solved
Hello,
I'm currently working on a batch file, at the beginning of which a program starts and my batch file pauses, but I would like the batch to continue as soon as the launched process closes.
Does anyone have a solution?

PS: I'm using Windows XP.

6 answers

  1. Hello,
    To make a process blocking with MS-DOS, you just need to use the start command like this:
     start /wait path\file.exe 
    8
    1. Meeeeeeeeeeeeeeeeeeeeeeeeerrrrrrrrrrrrrrrrrrrrrrrrrrrrrkkkkkkkkkkksss
      thank you so much I've been looking for this for........................
      0
    2. I LOVE YOU
      really
      0
  2. With start
    3
    1. Hello,

      Try with a CALL instead; the START does not "hand over" to the caller.
      --
      Sincerely.

      Christian.
      0
    2. @cchristianHonestly, this is the second time you've helped me; you're a BOSS in MS-DOS! Thank you!
      0
    3. Hmm, quite effective, but I have a case that it doesn't solve: how to know when an InstallShield has finished??
      The latter creates a clone process, so just calling isn't enough :(

      I tried with different IS parameters (including /deleter and /clone_wait or /wait_clone), but nothing changed :(
      0
    4. Well, I've found a solution that works for my case, using a VBScript (.vbs)

      Here is my code, if the formatting doesn't ruin it, you just need to copy/paste it to run it.

      Basically, in my case, I simply wait for two processes (those of an InstallShield) to finish before continuing execution.

      The code I present here is just a waiting script, which is called beforehand by a batch that launches various other batches via calls.
      i.e.:
      call batch1.bat
      call batch2.bat
      call wait.vbs
      call batch3.bat
      etc...

      'Script that waits for the end of the InstallShield process to allow installations to continue.
      'I have always seen the same two processes on the machines: _INS5576._MP & _ISDEL.EXE
      'If for any reason the created processes have different names, you will have to launch the steps manually,
      'or find a more reliable way to automate installations.

      wscript.sleep 5000 ' Wait a bit to make sure the install has started

      set svc=getobject("winmgmts:root\cimv2")
      sQuery1="select * from win32_process where name='_INS5576._MP'" ' Name of the process to wait for
      sQuery2="select * from win32_process where name='_ISDEL.EXE'" ' Name of the process to wait for
      set cproc1=svc.execquery(sQuery1)
      set cproc2=svc.execquery(sQuery2)
      iniproc=cproc1.count + cproc2.count 'Number of processes with the searched name
      Do While iniproc > 0 'Loop while at least one is still running
      wscript.sleep 1333 'Relatively passive wait
      set svc=getobject("winmgmts:root\cimv2")
      set cproc1=svc.execquery(sQuery1)
      set cproc2=svc.execquery(sQuery2)
      iniproc=cproc1.count + cproc2.count
      Loop
      set cproc1=nothing 'Release memory?? of system variables??
      set cproc2=nothing
      set svc=nothing

      'Set WshShell = WScript.CreateObject("WScript.Shell")
      'WshShell.Run "%windir%\notepad.exe", 1, True 'launching a program once the expected ones are finished
      'Set WshShell = Nothing
      0
  3. Good evening,

    Your batch launches another batch if I understood correctly?

    What command is used to activate this called program, CALL, START .............

    --
    Best regards.

    Cchristian.
    1
    1. MS-DOS is a single-tasking system (one command at a time) so there's no need to put in code to wait for the process to finish, it happens already.

      If you want to wait a little:
       ping localhost > NUL 

      @+
      0
      1. ok I'm going to give it a try
        0
        1. Good evening,

          Thank you, keep us informed,
          --
          Best regards.

          Christian.
          0
      2. It was indeed that.
        0
        1. Hello,

          Thank you for the feedback,
          --
          Best regards.

          Christian.
          0