I have an requirement to run one EXE. It will take 7 para开发者_C百科meters out of which one parameter is dynamic. Could some one help me how to run the EXE by passing dynamic parameters using bat file.
Thanks Chaitanya
If you need to execute a command with a dynamic number of parameters you can use %*
.
Example Command:
foo.exe [options] <file1> <file2> ...
Say you wanted to have a batch script which sets some options but still passes a dynamic number of files
foo.bat
@ECHO OFF;
foo.exe -some -option %*
Running:
foo.bat file1.txt file2.txt
Translates To:
foo.exe -some -option file1.txt file2.txt
If you want to run this :
my_7_param_program.exe p1 p2 p3 p4 p5 p6 p7
With, say, p4 as a dynamic parameter, try this batch file:
@my_7_param_program.exe p1 p2 p3 %1 p5 p6 p7
and call it like this :
c:\> my_batch.bat 42
So the actual call will be
my_7_param_program.exe p1 p2 p3 42 p5 p6 p7
With the p1, p2, p3, p5, p6 and p7 hardcoded parameters.
check this: http://ss64.com/nt/for_cmd.html
The for command allows running commands with the result of another command.
精彩评论