문제

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.

도움이 되었습니까?

해결책

:EXEC_CMD
set cmd=%*
echo Executuing cmd: %cmd%
CALL %cmd%
rem *** check some stuff and end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top