Page 1 of 1

Batch script stops forever when calling external exe program?

Posted: 02 Jul 2018 03:35
by pstein
From within a ODS batch script I call/start an external program similar to

...
D:\aaa\bbb\ccc\NetTraffic.exe
Echo after call
....

Yes, the external program is successfully started but the script does NOT continue to run.
The Echo statement is never executed.
Is this normal?

That would mean I always have to call/start external programs by

start "" /B C:\WINDOWS\system32\cmd.exe /c "D:\aaa\bbb\ccc\NetTraffic.exe"

Is this true?

Peter

Re: Batch script stops forever when calling external exe program?

Posted: 02 Jul 2018 06:21
by Squashman

Code: Select all

start "" /B "D:\aaa\bbb\ccc\NetTraffic.exe"

Re: Batch script stops forever when calling external exe program?

Posted: 03 Jul 2018 18:58
by penpen
pstein wrote:
02 Jul 2018 03:35
Yes, the external program is successfully started but the script does NOT continue to run.
The Echo statement is never executed.
Is this normal?
If you call an external executables within a batch file using a statement formed of that executables location, name and some optional parameters, then the executable is part of this batch processing:
That means that as long as that executable is running the batch file is processing that statement.
The batch only proceeds after the statement has been processed, which means the external executable finished.

pstein wrote:
02 Jul 2018 03:35
That would mean I always have to call/start external programs by

start "" /B C:\WINDOWS\system32\cmd.exe /c "D:\aaa\bbb\ccc\NetTraffic.exe"

Is this true?
According to the above explaination:
No.

Here is an example (using the external executable "findstr.exe"):

Code: Select all

@echo off
echo Hello world!
@echo Test: OK. | findstr "^"
echo Bye.
pause
Another example (using the external executable "findstr.exe") where the external executable won't finish until you enter a line containing the special key kombination CTRL+Z only:

Code: Select all

@echo off
echo Hello world!
findstr "^"
echo Bye.
pause
penpen