Breaking 2 exes in a command line

I have 2 exes to execute in a command line which purpose is to write to a d

\\fileA\program\Task1.exe
??
\\fileA\program\Task2.exe


The purpose of each task is to insert data into a table in 2 different servers.
For some strange thing that happened,Task1.exe has not completed the job yet and it hanged up. Meanwhile
Task2.exe also executed slowing the task. These took very long to finish.
I'd like to create a command line to check if Task1 finish without error before firing the Task2.exe.
zachvaldezAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it_saigeDeveloperCommented:
You can see if the task is still running before proceeding (described in a previous EE_PAQ - https:/Q_26733769.html); e.g. -
@ECHO OFF
START "" "\\fileA\program\Task1.exe"

:LOOP
TASKLIST | find /I "Task1.exe" > nul:
IF NOT errorlevel 1 goto :LOOP

START "" "\\fileA\program\Task2.exe"

:LOOP2
TASKLIST | find /I "Task2.exe" > nul:
IF NOT errorlevel 1 goto :LOOP2

Open in new window


-saige-
1
zachvaldezAuthor Commented:
Is it possible to display a message if completed at the end?
0
it_saigeDeveloperCommented:
Sure thing just add something like:
@ECHO OFF
START "" "\\fileA\program\Task1.exe"

:LOOP
TASKLIST | find /I "Task1.exe" > nul:
IF NOT errorlevel 1 goto :LOOP

START "" "\\fileA\program\Task2.exe"

:LOOP2
TASKLIST | find /I "Task2.exe" > nul:
IF NOT errorlevel 1 goto :LOOP2

ECHO "Tasks completed!!!"

Open in new window


-saige-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

zachvaldezAuthor Commented:
what does these lines mean? Thanks

:LOOP
TASKLIST | find /I "Task1.exe" > nul:
IF NOT errorlevel 1 goto :LOOP
0
it_saigeDeveloperCommented:
:LOOP - represents a label named LOOP.  It's basically a marker that you can use to *skip* to by way of a CALL or GOTO instruction.

TASKLIST - is a dos command that is used to "display all running applications and services with their Process ID (PID)", you can read more about TASKLIST here and here.

The | (or pipe) is a command redirection operator; the pipe is used to redirect the output of the TASKLIST command to the FIND command.  The FIND command has a paremeter /I which means that the search is not case-sensitive.  We are looking specifically for "Task1.exe".  

When we find "Task1.exe" we use the > sign to redirect both the std and error outputs to the null device.  With the output redirected we look at the errorlevel to determine if the call was successful or not.  If the process was found, we goto the LOOP label, otherwise we execute the next instruction.

Proof of concept:
@ECHO OFF
TASKLIST | FIND /I "NOTEPAD.EXE" > nul:
IF ERRORLEVEL 1 ( 
ECHO NOTEPAD WAS NOT FOUND!!!
GOTO EOF
) ELSE ( ECHO NOTEPAD WAS FOUND )
:EOF

Open in new window

Produces the following output when notepad is running:Capture.PNGAnd this output when notepad is not running:Capture.PNG
-saige-
1
Shaun VermaakTechnical SpecialistCommented:
ECHO OFF 
START /WAIT \\fileA\program\Task1.exe
START /WAIT \\fileA\program\Task2.exe
ECHO "Tasks completed!!!"

Open in new window

0
zachvaldezAuthor Commented:
Sorry for long time to response.
When Task1.exe, Can it check if an input file exist in C:\Assign folder.  and when it finishes delete the file.
0
Shaun VermaakTechnical SpecialistCommented:
When Task1.exe, Can it check if an input file exist in C:\Assign folder
Yes, and do what when it exist/do not exist?
0
zachvaldezAuthor Commented:
what's the command line? had to hard code the path
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.