2

I have this batch file:

@echo off
C:\Intel\computer_vision_sdk\bin\setupvars.bat

cd C:\Users\andre\Documents\Intel\OpenVINO\inference_engine_samples_2017\intel64\Debug

interactive_face_detection_demo.exe .....

I want execute this 3 commands but when it execute the first command the CMD closes and does not execute the remaining commands.

I already try de pause command but didn't work.

Dominique
  • 16,450
  • 15
  • 56
  • 112
  • maybe there is an exit in `setupvars.bat`? can you post the content of that as well? – Gerhard Feb 05 '19 at 11:49
  • @double-beep `call` fuction solved the problem. Thanks all – André Ferreira Feb 05 '19 at 11:57
  • @GerhardBarnard the `setupvars.bat` contains `exit /B 0` – André Ferreira Feb 05 '19 at 12:03
  • Yes, that is what I said in first comment :) – Gerhard Feb 05 '19 at 12:04
  • @GerhardBarnard: However, this is _not_ the problem. If `setupvars.bat` file is executed without `call` command, the result is the same even if it does _not_ contain an exit command... – Aacini Feb 05 '19 at 13:13
  • @Aacini depends whether we are referring to `exit` or `exit /b`. If we have `test.cmd` with `call test2.cmd & echo World` and inside `call2.cmd` we have `echo Hello & exit1` it will exit the cmd window before it `echo`s world from `test.cmd`. Call however does help if we have `exit /b` hence I asked op to check if there were any `exit` statements in `setuvars.bat` – Gerhard Feb 05 '19 at 15:24

1 Answers1

1

Using call solves your problem. If the file has somewhere an exit /b command, the cmd window will close. call prevents this from happening:

call C:\Intel\computer_vision_sdk\bin\setupvars.bat

However, if the setupvars.bat file contains an exit command, use start C:\Intel\computer_vision_sdk\bin\setupvars.bat, optionally with the /b flag.

double-beep
  • 5,031
  • 17
  • 33
  • 41