Windows .bat file command line tool, wait for keypress when double-clicked

Windows .bat files can be a convenient and quick way to automate things, like, for example, a compilation command involving a lot of options. They can be executed from the command line or by double-clicking them from the explorer. In the latter case, one would want the script to wait for a keypress until they close the window. When started from the command line, the waiting from a keypress is rather annoying.

It is possible to make the script behave differently depending on the way it was executed:

IF /I %0 EQU "%~dpnx0" PAUSE

This executes the PAUSE command when the file was started by double-click.

Source: Detect if bat file is running via double click or from cmd window