Batch file to determine if using Command Prompt

前端 未结 4 1756
时光说笑
时光说笑 2021-02-20 09:07

The last line in my batch file is pause. Is there any way to add a if condition to see if the script is run within command prompt or by double clicking to execute?

4条回答
  •  暖寄归人
    2021-02-20 09:37

    I know this is a year later but for future people searching you can use

    If /I "%COMSPEC%" == %CMDCMDLINE% Goto SkipPause
    pause
    :SkipPause
    

    It will skip the pause block if running from the command line and pause if running from batch file.

提交回复
热议问题