Pass a PAUSE command to a START command in a batch file












-1















Let's say I have a batch file with a bunch of lines each starting with START to run commands simultenously and I want each a new window that pops up to just pause when it's finished, instead of just closing, so that I could read the summary at the end.



start myapp.exe && pause doesn't work as the pause command just gets executed in the main window and doesn't get passed down with START. CMD /k works to prevent the window, but what I'd like to avoid that and use PAUSE.



It's important that I run these simultanously and I don't want to create a separate batch file for each line.



Any suggestions?










share|improve this question




















  • 2





    why would you want pause when cmd /k works better?

    – phuclv
    Nov 24 '18 at 1:49
















-1















Let's say I have a batch file with a bunch of lines each starting with START to run commands simultenously and I want each a new window that pops up to just pause when it's finished, instead of just closing, so that I could read the summary at the end.



start myapp.exe && pause doesn't work as the pause command just gets executed in the main window and doesn't get passed down with START. CMD /k works to prevent the window, but what I'd like to avoid that and use PAUSE.



It's important that I run these simultanously and I don't want to create a separate batch file for each line.



Any suggestions?










share|improve this question




















  • 2





    why would you want pause when cmd /k works better?

    – phuclv
    Nov 24 '18 at 1:49














-1












-1








-1








Let's say I have a batch file with a bunch of lines each starting with START to run commands simultenously and I want each a new window that pops up to just pause when it's finished, instead of just closing, so that I could read the summary at the end.



start myapp.exe && pause doesn't work as the pause command just gets executed in the main window and doesn't get passed down with START. CMD /k works to prevent the window, but what I'd like to avoid that and use PAUSE.



It's important that I run these simultanously and I don't want to create a separate batch file for each line.



Any suggestions?










share|improve this question
















Let's say I have a batch file with a bunch of lines each starting with START to run commands simultenously and I want each a new window that pops up to just pause when it's finished, instead of just closing, so that I could read the summary at the end.



start myapp.exe && pause doesn't work as the pause command just gets executed in the main window and doesn't get passed down with START. CMD /k works to prevent the window, but what I'd like to avoid that and use PAUSE.



It's important that I run these simultanously and I don't want to create a separate batch file for each line.



Any suggestions?







batch-file cmd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 15:45









double-beep

1,7132724




1,7132724










asked Nov 23 '18 at 22:03









TarhonyaaTarhonyaa

11




11








  • 2





    why would you want pause when cmd /k works better?

    – phuclv
    Nov 24 '18 at 1:49














  • 2





    why would you want pause when cmd /k works better?

    – phuclv
    Nov 24 '18 at 1:49








2




2





why would you want pause when cmd /k works better?

– phuclv
Nov 24 '18 at 1:49





why would you want pause when cmd /k works better?

– phuclv
Nov 24 '18 at 1:49












2 Answers
2






active

oldest

votes


















3














The start command can only used invoke a single internal or external command. To pass additional commands you have to pass the commands to a new instance of CMD and escape any special characters, to be able to pass them to the child process (CMD.EXE in this case).



start cmd /c myapp.exe ^& pause




As an addition, If command extensions are enabled (which is the default case) "CMD " can be used instead of just cmd or cmd.exe,...



Note that it has to be "CMD " with an extra space after CMD so it is different from "CMD"



Quoted from the start command help:




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

.

.

.

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.




So a safer approach would be



start "" "CMD " /c myapp.exe ^& pause


It is functionally equivalent to



start "" "%COMSPEC%" /c myapp.exe ^& pause


And because the first quoted argument to the start command will be interpreted as the windows title, A dummy title (in this case an empty title "") was passed as the first argument of the start command.






share|improve this answer

































    -1














    You just need to escape the && operator with ^ like: start myapp.exe ^&& pause



    But you better use the & operator that runs the second command no matter if the first command succeeds, otherwise if myapp.exe sets an error code, pause won't be run and the window will close before you can see it.






    share|improve this answer


























    • That doesn't work. &, &&, ^&&, ^&^& all just means there's a pause after each START so they're not passed down. Instead each pause just prevents running the next START in line automatically.

      – Tarhonyaa
      Nov 23 '18 at 23:37











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453368%2fpass-a-pause-command-to-a-start-command-in-a-batch-file%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    The start command can only used invoke a single internal or external command. To pass additional commands you have to pass the commands to a new instance of CMD and escape any special characters, to be able to pass them to the child process (CMD.EXE in this case).



    start cmd /c myapp.exe ^& pause




    As an addition, If command extensions are enabled (which is the default case) "CMD " can be used instead of just cmd or cmd.exe,...



    Note that it has to be "CMD " with an extra space after CMD so it is different from "CMD"



    Quoted from the start command help:




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

    .

    .

    .

    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.




    So a safer approach would be



    start "" "CMD " /c myapp.exe ^& pause


    It is functionally equivalent to



    start "" "%COMSPEC%" /c myapp.exe ^& pause


    And because the first quoted argument to the start command will be interpreted as the windows title, A dummy title (in this case an empty title "") was passed as the first argument of the start command.






    share|improve this answer






























      3














      The start command can only used invoke a single internal or external command. To pass additional commands you have to pass the commands to a new instance of CMD and escape any special characters, to be able to pass them to the child process (CMD.EXE in this case).



      start cmd /c myapp.exe ^& pause




      As an addition, If command extensions are enabled (which is the default case) "CMD " can be used instead of just cmd or cmd.exe,...



      Note that it has to be "CMD " with an extra space after CMD so it is different from "CMD"



      Quoted from the start command help:




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

      .

      .

      .

      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.




      So a safer approach would be



      start "" "CMD " /c myapp.exe ^& pause


      It is functionally equivalent to



      start "" "%COMSPEC%" /c myapp.exe ^& pause


      And because the first quoted argument to the start command will be interpreted as the windows title, A dummy title (in this case an empty title "") was passed as the first argument of the start command.






      share|improve this answer




























        3












        3








        3







        The start command can only used invoke a single internal or external command. To pass additional commands you have to pass the commands to a new instance of CMD and escape any special characters, to be able to pass them to the child process (CMD.EXE in this case).



        start cmd /c myapp.exe ^& pause




        As an addition, If command extensions are enabled (which is the default case) "CMD " can be used instead of just cmd or cmd.exe,...



        Note that it has to be "CMD " with an extra space after CMD so it is different from "CMD"



        Quoted from the start command help:




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

        .

        .

        .

        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.




        So a safer approach would be



        start "" "CMD " /c myapp.exe ^& pause


        It is functionally equivalent to



        start "" "%COMSPEC%" /c myapp.exe ^& pause


        And because the first quoted argument to the start command will be interpreted as the windows title, A dummy title (in this case an empty title "") was passed as the first argument of the start command.






        share|improve this answer















        The start command can only used invoke a single internal or external command. To pass additional commands you have to pass the commands to a new instance of CMD and escape any special characters, to be able to pass them to the child process (CMD.EXE in this case).



        start cmd /c myapp.exe ^& pause




        As an addition, If command extensions are enabled (which is the default case) "CMD " can be used instead of just cmd or cmd.exe,...



        Note that it has to be "CMD " with an extra space after CMD so it is different from "CMD"



        Quoted from the start command help:




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

        .

        .

        .

        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.




        So a safer approach would be



        start "" "CMD " /c myapp.exe ^& pause


        It is functionally equivalent to



        start "" "%COMSPEC%" /c myapp.exe ^& pause


        And because the first quoted argument to the start command will be interpreted as the windows title, A dummy title (in this case an empty title "") was passed as the first argument of the start command.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 25 '18 at 12:09









        Gerhard Barnard

        7,30431131




        7,30431131










        answered Nov 24 '18 at 2:23









        sstsst

        7821510




        7821510

























            -1














            You just need to escape the && operator with ^ like: start myapp.exe ^&& pause



            But you better use the & operator that runs the second command no matter if the first command succeeds, otherwise if myapp.exe sets an error code, pause won't be run and the window will close before you can see it.






            share|improve this answer


























            • That doesn't work. &, &&, ^&&, ^&^& all just means there's a pause after each START so they're not passed down. Instead each pause just prevents running the next START in line automatically.

              – Tarhonyaa
              Nov 23 '18 at 23:37
















            -1














            You just need to escape the && operator with ^ like: start myapp.exe ^&& pause



            But you better use the & operator that runs the second command no matter if the first command succeeds, otherwise if myapp.exe sets an error code, pause won't be run and the window will close before you can see it.






            share|improve this answer


























            • That doesn't work. &, &&, ^&&, ^&^& all just means there's a pause after each START so they're not passed down. Instead each pause just prevents running the next START in line automatically.

              – Tarhonyaa
              Nov 23 '18 at 23:37














            -1












            -1








            -1







            You just need to escape the && operator with ^ like: start myapp.exe ^&& pause



            But you better use the & operator that runs the second command no matter if the first command succeeds, otherwise if myapp.exe sets an error code, pause won't be run and the window will close before you can see it.






            share|improve this answer















            You just need to escape the && operator with ^ like: start myapp.exe ^&& pause



            But you better use the & operator that runs the second command no matter if the first command succeeds, otherwise if myapp.exe sets an error code, pause won't be run and the window will close before you can see it.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 23 '18 at 22:28

























            answered Nov 23 '18 at 22:22









            Juan LópezJuan López

            794




            794













            • That doesn't work. &, &&, ^&&, ^&^& all just means there's a pause after each START so they're not passed down. Instead each pause just prevents running the next START in line automatically.

              – Tarhonyaa
              Nov 23 '18 at 23:37



















            • That doesn't work. &, &&, ^&&, ^&^& all just means there's a pause after each START so they're not passed down. Instead each pause just prevents running the next START in line automatically.

              – Tarhonyaa
              Nov 23 '18 at 23:37

















            That doesn't work. &, &&, ^&&, ^&^& all just means there's a pause after each START so they're not passed down. Instead each pause just prevents running the next START in line automatically.

            – Tarhonyaa
            Nov 23 '18 at 23:37





            That doesn't work. &, &&, ^&&, ^&^& all just means there's a pause after each START so they're not passed down. Instead each pause just prevents running the next START in line automatically.

            – Tarhonyaa
            Nov 23 '18 at 23:37


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453368%2fpass-a-pause-command-to-a-start-command-in-a-batch-file%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Berounka

            Sphinx de Gizeh

            Different font size/position of beamer's navigation symbols template's content depending on regular/plain...