PC Review


Reply
Thread Tools Rate Thread

waiting for previous command to finish before executing next

 
 
djc
Guest
Posts: n/a
 
      14th Jul 2004
using sc.exe (manages services) as an example, when issuing several
commands one after another will the first finish before going on to the next
command? for example:

sc \\computername stop servicename
sc \\computername start servicename

1) will the service finish stopping before the next line issues the start
command in this case?
2) is it the default behavior of batch files to finish one command
completely before going to the next? or does it depend on the command?
3) If the answer is that each command completes before going on to the next,
which I think it is but I am looking for verification, is there a way to
change that? for example lets say each line of a batch file kicks of a file
copy process and you don't want to wait for each on to finish before going
on to the next one... how would you arrange that?

Thanks in advance... any info is greatly appreciated.


 
Reply With Quote
 
 
 
 
Mark V
Guest
Posts: n/a
 
      14th Jul 2004
In microsoft.public.win2000.cmdprompt.admin djc wrote:

> using sc.exe (manages services) as an example, when issuing
> several commands one after another will the first finish before
> going on to the next command? for example:
>
> sc \\computername stop servicename
> sc \\computername start servicename
>
> 1) will the service finish stopping before the next line issues
> the start command in this case?


The SC.EXE process itself will return before batch processing
continues to the next line. As to whether the STOP (or start or
pause or continue) command succeeds is a different question.

An additional issue for Service Control operation is that SC might
return before the SCM actually completes the operation. The usual
fix for this is to insert a wait into the batch between the commands.
Often: ping -n 6 127.0.0.1 >nul
or similar.

> 2) is it the default behavior of batch files to finish one command
> completely before going to the next? or does it depend on the


Yes.

> command? 3) If the answer is that each command completes before
> going on to the next, which I think it is but I am looking for
> verification, is there a way to change that? for example lets say
> each line of a batch file kicks of a file copy process and you
> don't want to wait for each on to finish before going on to the
> next one... how would you arrange that?


use the START command. START /?
...
START "" "<path>\sc" \\computername stop servicename
START "" "<path>\sc" \\computername stop servicename2
START "" "<path>\sc" \\computername stop servicename3
...

But once you start something in a new window, usually the parent
process (the batch) can no longer know as much about the child
proccess.

Note that many Win32 GUI programs run from then commandline return
control to CMD immediately and do not cause batch processing to wait.
That is usually the case too when an associated document is "run"
from cmd.


 
Reply With Quote
 
 
 
 
djc
Guest
Posts: n/a
 
      14th Jul 2004
great! thanks for all the info!

"Mark V" <(E-Mail Removed)> wrote in message
news:Xns9526112AFAE25z9zzaQ2btw@207.46.248.16...
> In microsoft.public.win2000.cmdprompt.admin djc wrote:
>
> > using sc.exe (manages services) as an example, when issuing
> > several commands one after another will the first finish before
> > going on to the next command? for example:
> >
> > sc \\computername stop servicename
> > sc \\computername start servicename
> >
> > 1) will the service finish stopping before the next line issues
> > the start command in this case?

>
> The SC.EXE process itself will return before batch processing
> continues to the next line. As to whether the STOP (or start or
> pause or continue) command succeeds is a different question.
>
> An additional issue for Service Control operation is that SC might
> return before the SCM actually completes the operation. The usual
> fix for this is to insert a wait into the batch between the commands.
> Often: ping -n 6 127.0.0.1 >nul
> or similar.
>
> > 2) is it the default behavior of batch files to finish one command
> > completely before going to the next? or does it depend on the

>
> Yes.
>
> > command? 3) If the answer is that each command completes before
> > going on to the next, which I think it is but I am looking for
> > verification, is there a way to change that? for example lets say
> > each line of a batch file kicks of a file copy process and you
> > don't want to wait for each on to finish before going on to the
> > next one... how would you arrange that?

>
> use the START command. START /?
> ...
> START "" "<path>\sc" \\computername stop servicename
> START "" "<path>\sc" \\computername stop servicename2
> START "" "<path>\sc" \\computername stop servicename3
> ...
>
> But once you start something in a new window, usually the parent
> process (the batch) can no longer know as much about the child
> proccess.
>
> Note that many Win32 GUI programs run from then commandline return
> control to CMD immediately and do not cause batch processing to wait.
> That is usually the case too when an associated document is "run"
> from cmd.
>
>



 
Reply With Quote
 
John Martin
Guest
Posts: n/a
 
      20th Jul 2004
why not use net stop servicename? it waits (unlike sc)

-john

"djc" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> great! thanks for all the info!
>
> "Mark V" <(E-Mail Removed)> wrote in message
> news:Xns9526112AFAE25z9zzaQ2btw@207.46.248.16...
> > In microsoft.public.win2000.cmdprompt.admin djc wrote:
> >
> > > using sc.exe (manages services) as an example, when issuing
> > > several commands one after another will the first finish before
> > > going on to the next command? for example:
> > >
> > > sc \\computername stop servicename
> > > sc \\computername start servicename
> > >
> > > 1) will the service finish stopping before the next line issues
> > > the start command in this case?

> >
> > The SC.EXE process itself will return before batch processing
> > continues to the next line. As to whether the STOP (or start or
> > pause or continue) command succeeds is a different question.
> >
> > An additional issue for Service Control operation is that SC might
> > return before the SCM actually completes the operation. The usual
> > fix for this is to insert a wait into the batch between the commands.
> > Often: ping -n 6 127.0.0.1 >nul
> > or similar.
> >
> > > 2) is it the default behavior of batch files to finish one command
> > > completely before going to the next? or does it depend on the

> >
> > Yes.
> >
> > > command? 3) If the answer is that each command completes before
> > > going on to the next, which I think it is but I am looking for
> > > verification, is there a way to change that? for example lets say
> > > each line of a batch file kicks of a file copy process and you
> > > don't want to wait for each on to finish before going on to the
> > > next one... how would you arrange that?

> >
> > use the START command. START /?
> > ...
> > START "" "<path>\sc" \\computername stop servicename
> > START "" "<path>\sc" \\computername stop servicename2
> > START "" "<path>\sc" \\computername stop servicename3
> > ...
> >
> > But once you start something in a new window, usually the parent
> > process (the batch) can no longer know as much about the child
> > proccess.
> >
> > Note that many Win32 GUI programs run from then commandline return
> > control to CMD immediately and do not cause batch processing to wait.
> > That is usually the case too when an associated document is "run"
> > from cmd.
> >
> >

>
>



 
Reply With Quote
 
djc
Guest
Posts: n/a
 
      26th Jul 2004
because, as far as I know, it cannot be used against remote servers.

"John Martin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> why not use net stop servicename? it waits (unlike sc)
>
> -john
>
> "djc" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > great! thanks for all the info!
> >
> > "Mark V" <(E-Mail Removed)> wrote in message
> > news:Xns9526112AFAE25z9zzaQ2btw@207.46.248.16...
> > > In microsoft.public.win2000.cmdprompt.admin djc wrote:
> > >
> > > > using sc.exe (manages services) as an example, when issuing
> > > > several commands one after another will the first finish before
> > > > going on to the next command? for example:
> > > >
> > > > sc \\computername stop servicename
> > > > sc \\computername start servicename
> > > >
> > > > 1) will the service finish stopping before the next line issues
> > > > the start command in this case?
> > >
> > > The SC.EXE process itself will return before batch processing
> > > continues to the next line. As to whether the STOP (or start or
> > > pause or continue) command succeeds is a different question.
> > >
> > > An additional issue for Service Control operation is that SC might
> > > return before the SCM actually completes the operation. The usual
> > > fix for this is to insert a wait into the batch between the commands.
> > > Often: ping -n 6 127.0.0.1 >nul
> > > or similar.
> > >
> > > > 2) is it the default behavior of batch files to finish one command
> > > > completely before going to the next? or does it depend on the
> > >
> > > Yes.
> > >
> > > > command? 3) If the answer is that each command completes before
> > > > going on to the next, which I think it is but I am looking for
> > > > verification, is there a way to change that? for example lets say
> > > > each line of a batch file kicks of a file copy process and you
> > > > don't want to wait for each on to finish before going on to the
> > > > next one... how would you arrange that?
> > >
> > > use the START command. START /?
> > > ...
> > > START "" "<path>\sc" \\computername stop servicename
> > > START "" "<path>\sc" \\computername stop servicename2
> > > START "" "<path>\sc" \\computername stop servicename3
> > > ...
> > >
> > > But once you start something in a new window, usually the parent
> > > process (the batch) can no longer know as much about the child
> > > proccess.
> > >
> > > Note that many Win32 GUI programs run from then commandline return
> > > control to CMD immediately and do not cause batch processing to wait.
> > > That is usually the case too when an associated document is "run"
> > > from cmd.
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Asp.net 2003 force method to finish before processing next Jerry J Microsoft C# .NET 4 5th Aug 2008 02:35 AM
Start more than one async methods but wait previous to finish before start next Nikolay Unguzov Microsoft C# .NET 4 23rd Apr 2007 03:27 PM
9 cents per print, plus 10% off - print digital photos online. All sizes from 4x6 up to 30x60. Same price for Matte finish and glossy finish nathan_usny Windows XP Print / Fax 0 6th Sep 2005 06:39 PM
Waiting a Form to Close before executing the next statement Roshan Abbasi via AccessMonster.com Microsoft Access Forms 2 19th Jul 2005 02:11 PM
?? MultiPage Cancel/Next/Previous/Finish Command Buttons ?? donna.gough@hydro.com Microsoft Excel Programming 3 27th May 2005 12:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:39 PM.