Alex Rivera | Logout

How to make windows batch file pause when double-clicked?

Asked 2009-05-20T08:36:51.850
14

This question is different to the one it's being marked as a duplicate of because that is about how to detect how the batch file was started from within the batch file. This question is about how to get the batch file to pause when double-clicked, but not pause when started from a console. I agree, there's some overlap. The answers to that question are one potential way of achieving what's being asked for. But, there are other ways and the accepted answer does not attempt to determine from within the batch file how it was started.


I've written a batch file to automate some tasks. I can run it from a command window and it runs and displays results. If I double click it from explorer though, it runs and terminates immediately so I can't see the results.

Is there a way I can make batch file window stay open until I dismiss it if I started it by double-clicking the icon?

I don't want to have to pass a /nopause parameter or something when I call a batch file from the command line. I'd like a solution where I can use the batch file without having to do anything too special?

Thanks.

NOTE I don't want it to pause when running from the command line!! I may call this batch file from another batch file to carry out a load of operations. In that case I can't be sitting there to keep hitting enter.

Edit
Report

2 Answers

-1

you can just add params to the batch call and handle conditionally pause statement in your batch. So when started from command line or dblclick the batch can pause, when called from others batches with a /nopause param don't pause.

answered 2009-05-20T08:52:37.810
-2

Would the pause command work?

Microsoft Documentation on pause

answered 2009-05-20T08:42:27.160

Your Answer