![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-23 14:46 |
47,812 topics / 349,917 posts / today 0 new / 48,273 members |
| DOS批处理 & 脚本技术(批处理室) » How to send the execution result of an .EXE to a batch file? |
| Printable Version 2,678 / 13 |
| Floor1 sunlight | Posted 2004-11-22 00:00 |
| 初级用户 Posts 15 Credits 160 | |
|
I want to send the result of executing .EXE as a string into a batch file and use it as a variable in the batch. How to achieve this? Thanks!
|
|
| Floor2 Climbing | Posted 2004-11-22 00:00 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
If you can describe the problem more clearly, I think your problem will be much easier to solve.
|
|
| Floor3 sunlight | Posted 2004-11-22 00:00 |
| 初级用户 Posts 15 Credits 160 | |
|
I now want to make the result of EXE running not return in the form of 0 or 1, but return a string, assign this string to a variable in the batch file, and compare it with the existing string in the batch file to see if the output characters are correct. How to implement it?
|
|
| Floor4 windrate | Posted 2004-11-22 00:00 |
| 初级用户 Posts 4 Credits 113 | |
|
Yeah! I also want to know! Please teach! !
|
|
| Floor5 Climbing | Posted 2004-11-22 00:00 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
The result returned by an EXE file is not determined by your subjective wishes, but by the EXE file itself. You can use the errorlevel environment variable to judge the result returned by the EXE file. Of course, your batch processing can judge what situation the EXE file encountered during execution according to the value of errorlevel and display it.
|
|
| Floor6 windrate | Posted 2004-11-22 00:00 |
| 初级用户 Posts 4 Credits 113 | |
|
By the way! Can we change to another solution! That is, write the required string into a file in the exe, and then the batch script reads the content of that file and assigns it to a variable for comparison?
|
|
| Floor7 hunter_han | Posted 2004-11-26 00:00 |
| 初级用户 Posts 1 Credits 104 | |
|
It can be achieved with setinfo.exe
|
|
| Floor8 bush | Posted 2004-11-29 00:00 |
| 银牌会员 Posts 730 Credits 2,165 | |
| Floor9 willsort | Posted 2004-12-04 00:00 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re windrate: This is certainly possible, provided that you can modify this program, whether it's modifying the source code or disassembling it. Additionally, outputting the program results to the system environment variables seems to be an old topic, and many solutions have emerged, but generally, it's to first generate a string similar to "set var=string" and then execute it as a command. Under moderate restrictive conditions (command extensions and third-party programs not allowed), you can use debug to generate a string prefix file, then append the program output to this file, and finally run it as a batch program. Under the highest restrictive conditions (command extensions and external commands not allowed), you can use a pre-edited string prefix file. Of course, you can also use the specific output of other specific commands (which may be internal or external commands), which is more complicated.
|
|
| Floor10 zybird | Posted 2005-01-21 00:00 |
| 中级用户 Posts 53 Credits 240 | |
|
Is this EXE you wrote yourself? If so, you can take a look at this, which explains this method: http://www.doshome.com/bbs/dispbbs.asp?boardID=5&ID=7288
|
|
| Floor11 笨的可以 | Posted 2005-01-21 00:00 |
| 初级用户 Posts 7 Credits 114 | |
|
What the 3rd said is right. The redirection function means: your EXE program > result file name.
|
|
| Floor12 kavenlee72 | Posted 2005-02-21 00:00 |
| 中级用户 Posts 87 Credits 369 | |
|
If there is a return code (errorlevel), it's easy. Please see:
if errorlevel 1 set el=you are right if errorlevel 2 set el=you are wrong if %el%==you are right goto XXX if %el%==you are wrong goto YYY |
|
| Floor13 gmy | Posted 2005-02-21 00:00 |
| 版主 Posts 392 Credits 1,113 | |
|
The key commands used are: > redirect to file, strings or inifile read strings. For the specific method, please refer to the help yourself.
|
|
| Floor14 DOSforever | Posted 2005-02-22 00:00 |
| 金牌会员 Posts 2,239 Credits 4,639 | |
The following is the speech of sunlight on 2004-11-22 9:36:43: If you must follow your idea, 4DOS can help you achieve it. It has a screen reading function, and then you can directly assign the read content to a variable. Of course, if you want to use this as a judgment condition for execution, you must know all possible execution results of the.EXE |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |