Batch File Tips

  • check if run by double click, or from the command line prompt
    ** [http://stackoverflow.com/questions/6796319/batch-file-to-determine-if-using-command-prompt http://stackoverflow.com/questions/6796319/batch-file-to-determine-if-using-command-prompt] second answer:
    If /I “%COMSPEC%” == %CMDCMDLINE% Goto SkipPause
    pause
    :SkipPause
    ** even if “call”ed, the result is the same.
    ** when “call”ed, %CMDCMDLINE% doesn’t change, i.e., it remains the same during the entire execution of cmd.exe. therefore to discriminate this case, use findstr to compare %CMDCMDLINE% with %0. do not forget to \ to \, since findstr uses regexp .

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.