Determining if batch script has been started/executed from the command line (cmd) -or- To pause or not to pause?

后端 未结 9 2139
眼角桃花
眼角桃花 2021-02-01 17:34

I like to have a typical \"usage:\" line in my cmd.exe scripts — if a parameter is missing, user is given simple reminder of how the script is to be used.

9条回答
  •  忘了有多久
    2021-02-01 17:54

    Here, I wrote something...

    Usage.bat


    @echo off
    if arg%1==arg goto help
    goto action
    
    :action
    echo do something...
    goto end
    
    :help
    set help1=This is Help line 1.
    set help2=This is Help line 2.
    cmd.exe /k "echo %help1% &echo %help2%"
    goto end
    
    :end
    

    It's not perfect, but it works! :D

    -joedf

提交回复
热议问题