Why is my batch file exiting after the pause command?

Robert Martin 1 Reputation point
2022-08-02T15:19:15.427+00:00

I have put a pause command in the middle of my batch file, and it exits, even though it's not the end of the file.
Here's an example to describe my situation:

title Echo  
:start  
echo Welcome to Echo  
pause  
text=  
echo %text%  

The pause command stops the program after pressing any key.

Azure Batch
Azure Batch
An Azure service that provides cloud-scale job scheduling and compute management.
302 questions
{count} votes

1 answer

Sort by: Most helpful
  1. srbhatta-MSFT 8,546 Reputation points Microsoft Employee
    2022-08-03T08:39:41.953+00:00

    Hello @Robert Martin ,
    Welcome to Microsoft QnA.
    Pause command ideally suspends the processing of a batch program, but you can press any key for it to continue, except CTRL+C and then Y (only then it is ideally supposed to stop the batch program). However, I have seen people face issues similar to yours.
    I have found a Stack Overflow thread relevant to your situation, can you check it and let me know if it helps? If it doesn't help, please respond back to me and tag me and I shall look further into debugging it. Thank You.

    Thread reference -> Batch-file-command-pause-does-not-work

    ----------------

    Please accept as answer and upvote if the above provide information was helpful so that the relevancy of this post on community increases.

    0 comments No comments