Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Batch File Run Exe  in cmd - wait til complete and exit

Posted on 2014-03-24
13
Medium Priority
?
12,821 Views
Last Modified: 2014-03-28
Hi!

How do I create a batch file that runs through cmd, waits until a process is complete and closes?
0
Comment
Question by:Annette Wilson, MSIS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
  • +1
13 Comments
 
LVL 25

Expert Comment

by:chaau
ID: 39952064
Just use command "call", like this:
call notepad.exe
call calc.exe

Open in new window

Save this as a file with an extension of bat. Run it. You will see that notepad opens first. The batch file will wait until you close the notepad. Then calculator will popup. The batch file will remain open until you close the calculator
0
 
LVL 3

Expert Comment

by:englanddg
ID: 39952161
@chaau has it!
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 39952579
Often that does not work, because CALL does not wait for the process to finish.
start /w "" notepad
forces the wait.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:Annette Wilson, MSIS
ID: 39960089
ok,

So, I'm using:

Start  /WAIT C:\Srcripts\myscript.exe  

But the script starts another process.  I want to close everything when the other process is complete.
0
 
LVL 25

Expert Comment

by:chaau
ID: 39960252
What is not closing when the other process finishes? Can you show us the screenshot
0
 

Author Comment

by:Annette Wilson, MSIS
ID: 39960266
I don't have a screen shot to show at this time because running the script may interrupt production.

Myscript.exe is an autoIT script that opens windows, sets up certain values, runs an executable file and sends an email.  

Is there a way to have the batch file wait for a specific process to complete then close everything when it is complete?
0
 
LVL 25

Expert Comment

by:chaau
ID: 39960282
the START /w command will wait for Myscript.exe. However, if Myscript.exe does not wait for other processes and exits after initiating them then you need to adjust the AutoIT script to wait.
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 39960385
There are means to wait for a specific process to finish, if nothing else eorks:
:wait
tasklist /im notepad.exe >nul && goto wait

Open in new window

0
 

Author Comment

by:Annette Wilson, MSIS
ID: 39960546
@chaau,

It's been a real challenge trying to get my autoIT script to wait.  It doesn't even wait until windows close before it send the email which should only send after the line items are complete.

I have the scripts set up on each of the servers.  Will let you know what works.
0
 
LVL 25

Expert Comment

by:chaau
ID: 39960556
Why don't you then just move all the script to a batch file and run it from there. What is the advantage to use the autoIT script?
0
 

Author Comment

by:Annette Wilson, MSIS
ID: 39960765
I'm using AutoIT because it does open the windows and run the program as and has the email feature.  Don't know that a batch file can do all of this.
0
 
LVL 25

Accepted Solution

by:
chaau earned 1000 total points
ID: 39960769
Batch files can't, but a simple vbs script can
0
 

Author Comment

by:Annette Wilson, MSIS
ID: 39961852
Thanks chaau.  It looks like I will have to get this done quickly using VBScripting.  This particular solution is not working for me.  I will post another question for help on VB Scripting.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question