2015-04-18 35 views
0

我通過BAT文件啓動一些exe文件,並且我想將這個exe文件的輸出保存在變量中。我試過了:BAT文件:從exe文件讀取輸出

:: exe file writes some text into the output stream. I need 
:: save this text in the variable. 
SET value = call "%~dp0\sr.exe" 
:: but variable has nothing: 
ECHO value 

我該怎麼辦?

回答

0

您使用for /f循環。請參閱for /?。這很簡單。

for /f "delims=" %A in ('dir') do echo %A 

在批處理for循環使用%%A而不是%A交互。