Asynchronous Command

G

Guest

I would like to write a batch file that utilizes an asynchronous command to a
line of code. The next line of code would not be run until the process of
the asynchronous command finishes. Does anyone know of such a command? I
know this can be done by using VBA and the SHELL command but want to have it
in a batch file command. Thanks-John
 
D

David H. Lipman

Use; START /wait

Execute CMD.EXE and execute; start /?
for syntax.

--
Dave




| I would like to write a batch file that utilizes an asynchronous command to a
| line of code. The next line of code would not be run until the process of
| the asynchronous command finishes. Does anyone know of such a command? I
| know this can be done by using VBA and the SHELL command but want to have it
| in a batch file command. Thanks-John
 
G

Guest

David,

I tried using the START /wait command and it does not work. The next line
of code kicks off and steps all over the first line. The first line of code
starts an application which eventually creates a file. The second line of
code renames the file which was created by the application called in the
first line of code.
 
T

Torgeir Bakken \(MVP\)

John said:
David,

I tried using the START /wait command and it does not work. The next line
of code kicks off and steps all over the first line. The first line of code
starts an application which eventually creates a file. The second line of
code renames the file which was created by the application called in the
first line of code.
Hi

--------------------8<----------------------
@echo off
start /wait notepad.exe
echo Testing...
pause
--------------------8<----------------------

If I run the above code, I do not see the "Testing..." echo
until I close Notepad.
 
S

Steve N.

John said:
I would like to write a batch file that utilizes an asynchronous command to a
line of code. The next line of code would not be run until the process of
the asynchronous command finishes. Does anyone know of such a command? I
know this can be done by using VBA and the SHELL command but want to have it
in a batch file command. Thanks-John

Use the CALL <filename> command in the batch file to reference another
batch file or command, the rest of the batch file will not progress
until the processes finish from the called file and returns control to
the originating batch file.

Steve
 
G

Guest

Steve,

The CALL processes the second line of code without waiting for the CALL to
finish.

John
 
D

David H. Lipman

Try using the following syntax...

%comspec% /k start /wait command_to_wait_for

or

cmd /k start /wait command_to_wait_for

Dave




| Steve,
|
| The CALL processes the second line of code without waiting for the CALL to
| finish.
|
| John
|
| "Steve N." wrote:
|
| > John wrote:
| >
| > > I would like to write a batch file that utilizes an asynchronous command to a
| > > line of code. The next line of code would not be run until the process of
| > > the asynchronous command finishes. Does anyone know of such a command? I
| > > know this can be done by using VBA and the SHELL command but want to have it
| > > in a batch file command. Thanks-John
| >
| > Use the CALL <filename> command in the batch file to reference another
| > batch file or command, the rest of the batch file will not progress
| > until the processes finish from the called file and returns control to
| > the originating batch file.
| >
| > Steve
| >
 
D

David H. Lipman

Ooops !
Scratch the other reply...

Try the syntax...

%comspec% /c start /wait command_to_wait_for

or

cmd /c start /wait command_to_wait_for

--
Dave




| Steve,
|
| The CALL processes the second line of code without waiting for the CALL to
| finish.
|
| John
|
| "Steve N." wrote:
|
| > John wrote:
| >
| > > I would like to write a batch file that utilizes an asynchronous command to a
| > > line of code. The next line of code would not be run until the process of
| > > the asynchronous command finishes. Does anyone know of such a command? I
| > > know this can be done by using VBA and the SHELL command but want to have it
| > > in a batch file command. Thanks-John
| >
| > Use the CALL <filename> command in the batch file to reference another
| > batch file or command, the rest of the batch file will not progress
| > until the processes finish from the called file and returns control to
| > the originating batch file.
| >
| > Steve
| >
 
A

Alex Nichol

John said:
I would like to write a batch file that utilizes an asynchronous command to a
line of code. The next line of code would not be run until the process of
the asynchronous command finishes. Does anyone know of such a command?

Try running via the Start command, with the /W switch to wait for
completion before carrying on
 
G

Guest

David,

I tried both and it did not work. It appears the issue relates to the file
not being completely written in my line 01 of code.
 
D

David H. Lipman

Switch to Kixtart (http://kixtart.org Kixtart is CareWare)

Is has both..
shell()
run()

Shell() -- runs the command in the bracket and waits for its completion before executing the
next line of code.
Run() -- runs the command in the bracket and continues to the next line of code

--
Dave




| David,
|
| I tried both and it did not work. It appears the issue relates to the file
| not being completely written in my line 01 of code.
|
| "David H. Lipman" wrote:
|
| > Ooops !
| > Scratch the other reply...
| >
| > Try the syntax...
| >
| > %comspec% /c start /wait command_to_wait_for
| >
| > or
| >
| > cmd /c start /wait command_to_wait_for
| >
| > --
| > Dave
| >
| >
| >
| >
| > | > | Steve,
| > |
| > | The CALL processes the second line of code without waiting for the CALL to
| > | finish.
| > |
| > | John
| > |
| > | "Steve N." wrote:
| > |
| > | > John wrote:
| > | >
| > | > > I would like to write a batch file that utilizes an asynchronous command to a
| > | > > line of code. The next line of code would not be run until the process of
| > | > > the asynchronous command finishes. Does anyone know of such a command? I
| > | > > know this can be done by using VBA and the SHELL command but want to have it
| > | > > in a batch file command. Thanks-John
| > | >
| > | > Use the CALL <filename> command in the batch file to reference another
| > | > batch file or command, the rest of the batch file will not progress
| > | > until the processes finish from the called file and returns control to
| > | > the originating batch file.
| > | >
| > | > Steve
| > | >
| >
| >
| >
 
G

Guest

I have just about tried everything except a 3rd party software solution. It
appears that the file being written takes quite a long time before it is
finalized and there is no ansynchronous solution available within a batch
file. The best I could do is break the two lines of code into two seperate
batch files and scheduled tasks. The first task to create the file and the
second task to rename the file later in the day.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top