[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4469
  • Last Modified:

dos batch file to start multiple executables sequentially

How do I tell one batch file to start multiple executables one after another? I know you can do:

start /w C:\"program files"\prog1.exe
start /w C:\"program files"\prog2.exe

but does the "/w" tell it to wait until prog1.exe is completely done and quits THEN start prog2.exe? I don't wnat that, I want it to start prog1.exe and leave it to run in the background, then start prog2.exe ...please tell me if I'm not understanding the "start" command correctly or if there's any other way to do what I want...

thanx!
0
jade03
Asked:
jade03
  • 4
  • 3
1 Solution
 
LeeTutorretiredCommented:
Yes, the "/w" tells Windows to wait for completion of the previous program before starting the current one.  Here are the possible parameters for Start:

Starts a separate window to run a specified program or command.

START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/WAIT] [/B] [command/program]
      [parameters]

    "title"     Title to display in  window title bar.
    path        Starting directory
    B           Start application without creating a new window. The
                application has ^C handling ignored. Unless the application
                enables ^C processing, ^Break is the only way to interrupt
                the application
    I           The new environment will be the original environment passed
                to the cmd.exe and not the current environment.
    MIN         Start window minimized
    MAX         Start window maximized
    SEPARATE    Start 16-bit Windows program in separate memory space
    SHARED      Start 16-bit Windows program in shared memory space
    LOW         Start application in the IDLE priority class
    NORMAL      Start application in the NORMAL priority class
    HIGH        Start application in the HIGH priority class
    REALTIME    Start application in the REALTIME priority class
    ABOVENORMAL Start application in the ABOVENORMAL priority class
    BELOWNORMAL Start application in the BELOWNORMAL priority class
    WAIT        Start application and wait for it to terminate
    command/program
                If it is an internal cmd command or a batch file then
                the command processor is run with the /K switch to cmd.exe.
                This means that the window will remain after the command
                has been run.

                If it is not an internal cmd command or batch file then
                it is a program and will run as either a windowed application
                or a console application.

    parameters  These are the parameters passed to the command/program


If Command Extensions are enabled, external command invocation
through the command line or the START command changes as follows:

non-executable files may be invoked through their file association just
    by typing the name of the file as a command.  (e.g.  WORD.DOC would
    launch the application associated with the .DOC file extension).
    See the ASSOC and FTYPE commands for how to create these
    associations from within a command script.

When executing an application that is a 32-bit GUI application, CMD.EXE
    does not wait for the application to terminate before returning to
    the command prompt.  This new behavior does NOT occur if executing
    within a command script.

When executing a command line whose first token is the string "CMD "
    without an extension or path qualifier, then "CMD" is replaced with
    the value of the COMSPEC variable.  This prevents picking up CMD.EXE
    from the current directory.

When executing a command line whose first token does NOT contain an
    extension, then CMD.EXE uses the value of the PATHEXT
    environment variable to determine which extensions to look for
    and in what order.  The default value for the PATHEXT variable
    is:

        .COM;.EXE;.BAT;.CMD

    Notice the syntax is the same as the PATH variable, with
    semicolons separating the different elements.

When searching for an executable, if there is no match on any extension,
then looks to see if the name matches a directory name.  If it does, the
START command launches the Explorer on that path.  If done from the
command line, it is the equivalent to doing a CD /D to that path.

0
 
jade03Author Commented:
LeeTutor,

My apologies if the grade I gave out was below that of your expectation, but honestly speaking, I did resolve it on my own prior to seeing your suggested solution. Also, your solution really wasn't helpful to me because I've done a search prior to posting this question, and have came upon the exact same solution posted by someone...

To me, this kind of solution seemed like you simply typed "help" or "man" in dos and grabbed whatever the screen printed out...I could've done that myself, and in fact, I did, and didn't find that screen dump too helpful, that's why I thought I'd post a question here to see if someone could actually offer an alternative explanation that's more concise and straight to the point without my having to sort through all the parameters of the "start" function in dos.

As for "emotions", I think you're reading WAY too much into a simple grade.

Thanx for the effort, nonetheless. I certainly don't wanna lose you as a potential helper in the future. :)
0
 
LeeTutorretiredCommented:
>To me, this kind of solution seemed like you simply typed "help" or "man" in dos and grabbed whatever the screen printed out...I could've done that myself, and in fact, I did, and didn't find that screen dump too helpful

So why didn't you respond with a comment in your question explaining all this, rather than just asking for the question to be deleted, and with no explanation of what the solution was that you found?

Did you read those links to the help pages about communicating, etc., that I gave?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
jade03Author Commented:
Lunchy,

Thanx for mediating. I don't have an issue with changing the grade to a B if that'll help mitigate the trauma in LeeTutor's behalf.

Again, my apologies for not scrutinizing the policies and guidelines; Will defnitely be more acute in evaluating resolutions next time.

BTW, here's how I solved the issue to my original problem, simply take out the "/w" parameter from the Start function:

start C:\"program files"\prog1.exe
start C:\"program files"\prog2.exe

That allows both programs to run concurrently without having the 2nd one wait for the first one to finish before starting.

I wish the help screen would mention that. :)
0
 
LeeTutorretiredCommented:
>BTW, here's how I solved the issue to my original problem, simply take out the "/w" parameter from the Start function
>That allows both programs to run concurrently without having the 2nd one wait for the first one to finish before starting.
>I wish the help screen would mention that.


I see what you mean.  I guess Microsoft made the same assumption that I did when I read their help documentation: that leaving off that parameter would change the operation of the Start command to not waiting, which was so "obvious" it didn't need stating.  But I guess it isn't obvious, really...  Anyway, thanks for changing the grade. And "Jade03" has been REMOVED from my "don't answer" list as a result.

0
 
jade03Author Commented:
Yah, my first instinct when I first learned of the start function was to just use it w/o any additional params besides the given path (which is correct), but somehow it wouldn't run...or who knows what happened....so in looking into it some more I found an example with the "/w" param added to it...so then I tried to use that, and it would just run the first exe and not the 2nd, that's when I thought this function is acting really strange...

but after fiddling w/ it a few more times it ran fine without the extra params!

anyhow, as long as it works, I'm happy. :)
0
 
LeeTutorretiredCommented:
By reading more of the help documentation, I came upon this, which might explain the problems you initially had with Start:

Bugs:
Although ["title"] is supposedly an optional parameter, when it is omitted other options may be interpreted as being the title - so to be absolutely sure just put something in like "My Script".
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now