0

I need to run a process from a Windows Batch file. This process has a GUI which needs user interaction. The batch script should then wait for a specific condition (ping to respond to be precise, because the GUI tool sets up a network connection) which will be triggered after the user interacted with the GUI process - but the GUI process will still (and needs to) run after user interaction! The batch script should in the meantime continue to run some aditional commands and then wait for the GUI process to finish and when the GUI process is finished do some other tasks.

So basically:

  1. start GUI process
  2. while ping not repsonding try ping (-> wait for user interaction with GUI)
  3. as soon as ping responds continue with batch, but not to the end, but:
  4. let batch script wait for GUI process to be terminated by user
  5. continue with rest of batch file

I know how to wait for processes (start /wait), but I not just need to wait for termination but also have the batch script running some (but not all commands) while the waiting process is running.

How would I do something like this?

Foo Bar
  • 1,764
  • 4
  • 24
  • 43

1 Answers1

1
  1. launch your GUI process (not waiting for)
  2. wait for ping response, cf. Pause a batch file until a host is reachable (using ping)
  3. analogously wait for your GUI process terminates using tasklist
Community
  • 1
  • 1
JosefZ
  • 28,460
  • 5
  • 44
  • 83
  • I can't get my batch file to launch the GUI process correctly. If I just do `path\to\gui.exe` it runs, but waits. If I do `start \path\to\gui.exe` the process starts but the window of gui.exe does not show. If I do `start /D path\to\ path\to\gui.exe` to set the working dir the problem still stays the same. – Foo Bar Nov 08 '14 at 11:20
  • 1
    What command do you use to start your process (exactly)? I'd use something like `start "" "\path\to\gui.exe"`: note the `""` empty string. All three cases verified with `"C:\Program Files\Bleucanard\Registry Grep\RegistryGrep.exe"` (no _ad_). – JosefZ Nov 08 '14 at 11:42
  • Ah, the empty string did it. :) – Foo Bar Nov 08 '14 at 12:07