How to make SHIFT work with %* in batch files

后端 未结 7 1858
独厮守ぢ
独厮守ぢ 2020-12-24 11:38

In my batch file on Windows XP, I want to use %* to expand to all parameters except the first.
Test file (foo.bat):



        
7条回答
  •  猫巷女王i
    2020-12-24 12:12

    Another easy way of doing this is:

    set "_args=%*"
    set "_args=%_args:* =%"
    
    echo/%_args%
    

    Remarks:

    • Does not work if first argument (%1) is 'quoted' or "double quoted"
    • Does not work if any argument contains the & char
    • Any extra spaces in between arguments will NOT be removed

提交回复
热议问题