Windows – How to make windows batch file pause when double-clicked


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?


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.

Ideally it would be best if I can put some code in the batch file so it can work out where it was started from, and then pause or not as appropriate.

Best Solution


cmd /K myBatch.bat

as your shortcut.