1

What I would like to do is write a generic execute command wrapper "method" in a batch file. Here is an example of the method I want:

:EXEC_CMD
set cmd=%~1
echo Executuing cmd: %cmd%
CALL %cmd%
rem *** check some stuff and end

This works for simple commands but when the commands I want to execute has parameters and they require quotes, then things do not work so well:

cmd to execute:

:EXEC_CMD "test.bat "arg1" "arg 2" "a r g 3""

output:

Executing cmd: test.bat "arg1" "arg

what is the best way to get the above to execute any command I give it? I tried escaping the nested double quotes and placing quotes in different spots but nothing has worked so far.

4

1 回答 1

2
:EXEC_CMD
set cmd=%*
echo Executuing cmd: %cmd%
CALL %cmd%
rem *** check some stuff and end
于 2013-10-09T19:10:54.510 回答