If your batch file contains a FOR command that is parsing a DIR /S command, such as:
for /f "Tokens=*" %%a in ('dir c:\ /b /s') do @echo %%a
the command may appear hang before returning any output.
The entire directory structure is parsed before the first line of output is returned.
To demonstrate this behavior, open a CMD prompt and type:
for /f "Tokens=*" %a in ('dir %systemroot% /b') do @echo %a
The output should be promptly returned. Now add the /S parameter by typing:
for /f "Tokens=*" %a in ('dir %systemroot% /b /s') do @echo %a
Notice the sizeable delay.
NOTE: The FOR command will exhibit this same behavior when processing the contents of a large file.