简体   繁体   中英

batch files command line arguments

hi i am setting a string 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

在第二个bat文件中;

@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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM