FOR /F with spaces doesn't work

Solution 1:

You need to set the delimiters used to split the line into tokens so that spaces aren't included. Something like "delims=?" Right after the /f. Just use a character that's illegal in filenames (? and * are good candidates)

FOR /F "delims=?" %%F in ('dir /b /s "%Dir%\Run.*.dll"') DO ECHO "%%F"

Just remember to put double quotes around the %%F in your actual commands as the expanded variable will have spaces in it as well.

Solution 2:

Why do you need to iterate over dir's output at all, here? Simply using

for /r %%F in ("%DeploymentDirectory%\Run.*.dll")

doesn't suffice?