If you have multiple jar files in your lib directory (i.e. diff-ing different RDBMs), the batch file will only include one of them in your classpath. This is apparently due to the use of SET in a dos FOR loop. SET is not evaluated until the for loop’s close so only the last thing in the set of files takes effect. The solution seems to be delayed variable expansion, but the requires the user to start a command prompt using CMD /v
Taken from the online SET help:
for %i in (*) do set LIST=%LIST% %i
in that it will NOT build up a list of files in the current directory,
but instead will just set the LIST variable to the last file found.
Again, this is because the %LIST% is expanded just once when the
FOR statement is read, and at that time the LIST variable is empty.
So the actual FOR loop we are executing is:
for %i in (*) do set LIST= %i
which just keeps setting LIST to the last file found.
Delayed environment variable expansion allows you to use a different
character (the exclamation mark) to expand environment variables at