Batch script stops forever when calling external exe program?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
pstein
Posts: 125
Joined: 09 Nov 2011 01:42

Batch script stops forever when calling external exe program?

#1 Post by pstein » 02 Jul 2018 03:35

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

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

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

#2 Post by Squashman » 02 Jul 2018 06:21

Code: Select all

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

penpen
Expert
Posts: 1996
Joined: 23 Jun 2013 06:15
Location: Germany

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

#3 Post by penpen » 03 Jul 2018 18:58

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

Post Reply