How to specified dependency in a .bat file

Hi,

I want to create a batch file, which executes two commands. The second one can not be executed until the first is completed. How do I do that?

Thank you.
LVL 1
jyhuangAsked:
Who is Participating?
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.

Lee W, MVPTechnology and Business Process AdvisorCommented:
Place them sequentially.  Batch files do not proceed without completing the previous task.

For example,  create a batch file that starts notepad and calculator -

notepad
calc

Then run it.  Note that when notepad starts, the "dos" window remains open with a flashing cursor.  When you close notepad, calc starts and the window will disappear - the batch file doesn't continue until the first program completes running.
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
Cherukuri30Service EngineerCommented:
by default the commands embedded in a batch file are executed in sequential order first is first and second is second.

OR

you looking for a conditional execution meaning if first command is executed then only the second should be executed some thing like if condition?
0
Lee W, MVPTechnology and Business Process AdvisorCommented:
Note, if your particular two programs don't function the same way in the batch file, the first program may do something differently, in which case there are several ways in which to keep the batch program from continuing until the first program is done.
0
Cherukuri30Service EngineerCommented:
look at the below example if you are looking for conditional execution

if not exist myfile.txt goto MESSAGE
echo The file does not exists on the current directory
goto END

MESSAGE
echo The file exists in the current directory.

:END

in the above example i am trying to find a file called myfile.txt is existing in the current directory or not if it finds the file then execution goes to the the label MESSAGE and displays the message.

If file is not found then the line below if statement will be displayed and the control execution will goto end of the program
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 Server 2003

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.