Question : Detect how cmd script started

Is it possible to detect whether cmd script was started from explorer or command line?

I need to add pause command at the end of the script if the script was run through icon-click for user to see results of the operation.

Answer : Detect how cmd script started

Here's the code I use for this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
@echo off
echo %CmdCmdLine% | find /i "cmd /c" >NUL
if errorlevel 1 (
  set PauseExplorer=
) else (
  set PauseExplorer=pause
)
 
echo Script start type detection.
echo Will only prompt for a key press if started from Explorer.
%PauseExplorer%
Random Solutions  
 
programming4us programming4us