I posted a solution to a similar question here: 886848/how-to-make-windows-batch-file-pause-when-double-clicked.
That solution should work for you, but it's is a bit more involved than you probably need.
I posted a shortened version of it below which is simpler and should work for you.
You can read more about it at the solution linked above, but the basics of it is that it uses the environment variable:
%cmdcmdline% to determine if the batch file was run from a command window or not.
It works because the contents of the variable
%cmdcmdline% are different depending on how the batch file was started: 1) By clicking on a batch file or shortcut, like from Windows Explorer or on the Desktop, or 2) Running the batch file from within a Command Prompt window.
So, you use it like this:
At the point where the batch file will exit, you add some code like this:
echo %newcmdcmdline% | find /i "cmd /c --%~dpf0%-"
rem if %result% EQU 0
rem this batch file was executed by clicking a batch file
rem or a shortcut to a batch file, typically from Windows Explorer
rem or the Desktop, or the "Start Menu" ...
rem if %result% NEQ 0
rem this batch file was executed from within a Command Prompt
rem if executed from within a Command Prompt:
rem go exit the batch script immediately, without pausing.
rem since this batch file was executed from within a
rem Command Prompt, the command window will remain open.
rem You can use either of these to exit the batch file:
rem goto :EOF
rem exit /b
if %result% NEQ 0 goto :EOF
rem at this point, we know this batch file was executed by clicking ...,
rem NOT from within a Command Prompt.
rem leave the command prompt window open to allow the user time to
rem view the messages on the screen before exiting. Use any of
rem these to pause and or interact with the user before exiting:
rem echo Message... &pause
rem set /p "d=Message..."
rem choice [Options...]
rem (choice /? Displays help message for the Choice command)
rem timeout /T wait-time [Options...]
rem (timeout /? Displays help message for the Timeout command)
timeout /t 10