Writing an EXE output to a batch file

杀马特。学长 韩版系。学妹 提交于 2019-12-23 18:44:41

问题


I have an EXE which will have the Output values as 0/1. The EXE is to be called via a batch file. I want the Batch file to run the EXE and write the output obtained. How is this possible? Any help would be appreciated.


回答1:


I asume that you want to capture the output of the EXE and process that value, instead of just printing that value. Here is how you can capture the output in a variable:

FOR /F "tokens=*" %%i IN ('%~dp0sometool.exe') DO SET TOOLOUTPUT=%%i 



回答2:


You need to the /F extension to the FOR loop.

for /F "tokens=*" %%i in ('call testing.exe') DO echo %%i



回答3:


How does the exe write its output? Is it just writing to the console? If so, you can direct it to a file using > or >>.

For example:

C:\>dir >> dir.txt

Creates a text file with the output of the dir command.

">" creates a new file each time while ">>" will append to the file if it exists already.



来源:https://stackoverflow.com/questions/4695570/writing-an-exe-output-to-a-batch-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!