开发者

Build a command and execute it from within a batch file

I have a batch file that outputs a list of commands which themselves can be executed at the command line.

Here is a simplified version of what I'm doing:

set %foldername%="c:\my_folder"
set %exename%="c:\my_utility.exe"

cd %foldername%
FOR /F "tokens=*" %%G IN ('dir *.xml /s /b /a:-d') DO @echo %exename% /x="%%G"

This basically outputs a batch file. It looks like this:

c:\my_utility.exe /x="c:\my_folder\file1.xml"
c:\my_utility.exe /x="c:\my_folder\file2.xml"
c:\my_utility.exe /x="c:\my_folder\file开发者_如何学运维3.xml"
c:\my_utility.exe /x="c:\my_folder\file4.xml"

I want to execute these commands. Currently I have to redirect the output to a batch file and then run that. Is there any way to just say "execute this command I just constructed" in the dos prompt?


Just remove echo in the FOR loop:

FOR /F "tokens=*" %%G IN ('dir *.xml /s /b /a:-d') DO %exename% /x="%%G"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜