开发者

batch files command line arguments

hi i am setting a 开发者_如何学JAVAstring in a variable

set main=svn commit -m "Build version number update" install\msbuild\VersionNumber.txt

and passing "%main%" as a command line argument to another script template.bat .

but in template.bat "Build version number update" is cosidered a 2nd arg and rest as 3rd

one.

please tell me how to pass the variable main as a single argument.

thanks


In the 2nd bat file;

@echo whole command line is %*


Variable %main% contains spaces, so if you use it like this:

template.bat %main%

Batch will interpret it like this:

template.bat svn blah blah blah

So %1 will be only "svn", etc. If you want entire contents of %main% to be treated as a single argument, you have to put quotes around it:

template.bat "%main%"

The problem is, the %1 now contains those quotes. You have to remove them inside template.bat using tilde:

%~1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜