Batch file to determine if using Command Prompt

前端 未结 4 1741
时光说笑
时光说笑 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:36

    CALL :GETMYSWITCH %CMDCMDLINE%
    IF /I "%MYSWITCH%" == "/C" ECHO I WAS STARTED IN THE EXPLORER & PAUSE
    IF /I NOT "%MYSWITCH%" == "/C" ECHO I WAS STARTED IN A DOS SESSION
    
    
    :GETMYSWITCH
    SET MYSWITCH=%2
    

提交回复
热议问题