批处理文件在第一个命令之后停止运行

我使用“ HTML 匹配”工具来比较两个 HTML 文件。因为我必须比较许多文件,所以我创建了一个批处理文件,如下所示。例如,我只给出五组文件。

cd "C:\Program Files\HTML Match"
HTMLMATCH.EXE "D:\Raj\compare1\a1.html" "D:\Raj\compare2\a1.html" "D:\Raj\compare_res\a1.html"
HTMLMATCH.EXE "D:\Raj\compare1\a2.html" "D:\Raj\compare2\a2.html" "D:\Raj\compare_res\a2.html"
HTMLMATCH.EXE "D:\Raj\compare1\a3.html" "D:\Raj\compare2\a3.html" "D:\Raj\compare_res\a3.html"
HTMLMATCH.EXE "D:\Raj\compare1\a4.html" "D:\Raj\compare2\a4.html" "D:\Raj\compare_res\a4.html"
HTMLMATCH.EXE "D:\Raj\compare1\a5.html" "D:\Raj\compare2\a5.html" "D:\Raj\compare_res\a5.html"

当我在 cmd 提示符中执行这个批处理文件时,只有第一行(即只有‘ a1.html’)进行比较并生成结果。然后死刑就停止了。

63425 次浏览

Add call in front of the commands you're running.

You can also change this to a for loop, so:

FOR /L %%i in (1,1,5) DO CALL HTMLMATCH.EXE D:\Raj\compare%%i%%\a%%i%%.html D:\Raj\compare%%i%%\a%%i%%.html D:\Raj\compare_res\a%%i%%.html

You don't have to insert quotation marks where there isn't any space mark between.

Try that:

HTMLMATCH.EXE D:\Raj\compare1\a1.html D:\Raj\compare2\a1.html D:\Raj\compare_res\a1.html

Maybe it will solve your issue.

The answer to your problem is to write CALL HTMLMATCH.EXE (and the rest of the parameters). Just use CALL in front of every executable command in the batch file.

I was looking for something really similar and tried, I think, all the replies left here but I finally found the solution to my problem!!

In my script I want to check if one process is running, if not, start it (a .exe) and then check if another process is running, if not, start it too (but leave all the programs opened) and the problem is that the first .exe was started but then not moving to the second one because it was waiting until the process ended. It´s finally working for me with start and the magic comes with...

/separate

it works for me as:

start "program1" /separate program1.exe
other commands

Before it stopped after starting program1 because it was waiting until it was closed, I think, but this was not going to happen because I wanted to leave it opened. Now with the start /separate it continues with the other commands.

I found it in another forum but the thing is that it´s the manual, /separate is used to start in another memory space.