When I first your first comment, and before reading the scipt you included, I was about to suggest "start /c ..." as well. But as it turned out for you, that was a/the problem. Btw, there are plenty crazy things about cmd.exe, enough to make Bash to appear quite sane, hehehe. No command substitution being one, you instead have to use:
for /f ["<options>"] %<single-letter-variable> in ('<substituted command>') do <processing command goes here, it has access to %single-letter-variable, which is the output of 'substituted command'>
(the percent character/sign must be doubled (%%) in scripts of course, single ones are only for immediate commandline)
And there are limitations as well as dangers with that workaround.
Also, sometimes in cmd.exe you have to use "cmd /c <command>" rather than just "<command>", or things won't behave as expected and break. It's a mess, and more so to remember all these exception-al behaviors.