windows %* 在批处理文件中是什么意思

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16144716/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:27:02  来源:igfitidea点击:

What does %* mean in a batch file

windowsbatch-filecmd

提问by feminkk

I have seen the usage of %* in batch files and command lines. Googling did not give me any results. Can some one explain the typical usage of %* with an example.Thanks

我已经在批处理文件和命令行中看到了 %* 的用法。谷歌搜索没有给我任何结果。有人可以用一个例子解释 %* 的典型用法吗?谢谢

回答by Jon

It means "all the parameters in the command line".

它的意思是“命令行中的所有参数”。

For example, it's useful when you want to forward the command line from your batch file to another program:

例如,当您想将命令行从批处理文件转发到另一个程序时,它很有用:

REM mybatchfile.cmd
echo You called this with arguments: %*
echo I will now forward these to the DIR command.
dir %*

回答by dbenham

One important point not listed in any of the previous answers: %*expands to allparameters from the command line, even after a SHIFToperation.

以前的任何答案中都没有列出的一个重要点:从命令行%*扩展到所有参数,即使在SHIFT操作之后也是如此。

Normally a SHIFTwill move parameter %2to %1, %3to %2, etc., and %1is no longer available. But %*ignores any SHIFT, so the complete parameter list is always available. This can be both a blessing and a curse.

通常 aSHIFT会将参数移动%2%1%3%2等,并且%1不再可用。但%*忽略 any SHIFT,因此完整的参数列表始终可用。这既可以是一种祝福,也可以是一种诅咒。

回答by David Heffernan

%*expands to the complete list of arguments passed to the script.

%*扩展为传递给脚本的参数的完整列表。

You typically use it when you want to call some other program or script and pass the same arguments that were passed to your script.

当您想要调用其他程序或脚本并传递与传递给您的脚本相同的参数时,通常会使用它。

回答by Michael Krupp

"The %* modifier is a unique modifier that represents all arguments passed in a batch file. You cannot use this modifier in combination with the %~ modifier. The %~ syntax must be terminated by a valid argument value."

“%* 修饰符是一个唯一的修饰符,表示批处理文件中传递的所有参数。您不能将此修饰符与 %~ 修饰符结合使用。%~ 语法必须以有效的参数值终止。”

See:

看: