Capture output command CMD
问题 Platform Windows XP When writing a command file (.bat) how can i "catch" the output from a command into a variable ? I want to do something like this SET CR='dir /tw /-c b.bat | findstr /B "[0-9]"' But this do not work Regards Stefan PS No, I can not dowload grep, cygwin or any other software, it have to be the CMD DS 回答1: You can use FOR /F and go through some loops inside a batch file to capture the output: @echo off setlocal enabledelayedexpansion set var= for /f "tokens=* delims=" %%i in