waiting for previous command to finish before executing next

Discussion in 'Microsoft Windows 2000 CMD Promt' started by djc, Jul 14, 2004.

  1. djc

    djc Guest

    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.
     
    djc, Jul 14, 2004
    #1
    1. Advertisements

  2. djc

    Mark V Guest

    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.
     
    Mark V, Jul 14, 2004
    #2
    1. Advertisements

  3. djc

    djc Guest

    great! thanks for all the info!

    "Mark V" <> 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.
    >
    >
     
    djc, Jul 14, 2004
    #3
  4. djc

    John Martin Guest

    why not use net stop servicename? it waits (unlike sc)

    -john

    "djc" <> wrote in message
    news:...
    > great! thanks for all the info!
    >
    > "Mark V" <> 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.
    > >
    > >

    >
    >
     
    John Martin, Jul 20, 2004
    #4
  5. djc

    djc Guest

    because, as far as I know, it cannot be used against remote servers.

    "John Martin" <> wrote in message
    news:...
    > why not use net stop servicename? it waits (unlike sc)
    >
    > -john
    >
    > "djc" <> wrote in message
    > news:...
    > > great! thanks for all the info!
    > >
    > > "Mark V" <> 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.
    > > >
    > > >

    > >
    > >

    >
    >
     
    djc, Jul 26, 2004
    #5
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike O'Neill

    Batch file won't finish

    Mike O'Neill, Oct 21, 2003, in forum: Microsoft Windows 2000 CMD Promt
    Replies:
    3
    Views:
    673
    Michael Bednarek
    Oct 23, 2003
  2. Greg

    Executing Commands on a Remote Computer

    Greg, Nov 17, 2003, in forum: Microsoft Windows 2000 CMD Promt
    Replies:
    1
    Views:
    266
    Torgeir Bakken (MVP)
    Nov 17, 2003
  3. Joe Lux

    Re: Executing Commands on a Remote Computer

    Joe Lux, Nov 18, 2003, in forum: Microsoft Windows 2000 CMD Promt
    Replies:
    0
    Views:
    250
    Joe Lux
    Nov 18, 2003
  4. John

    Command for finding internet connect before connection?

    John, Nov 22, 2003, in forum: Microsoft Windows 2000 CMD Promt
    Replies:
    2
    Views:
    376
    Jerold Schulman
    Nov 23, 2003
  5. Roy Frye

    Remotely executing a batch file.

    Roy Frye, Jan 13, 2004, in forum: Microsoft Windows 2000 CMD Promt
    Replies:
    3
    Views:
    681
    Torgeir Bakken (MVP)
    Jan 13, 2004
Loading...

Share This Page