![]() |
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 16:05 |
47,812 topics / 349,917 posts / today 0 new / 48,273 members |
| DOS批处理 & 脚本技术(批处理室) » How can the console automatically record all input commands and output them to a file? |
| Printable Version 2,407 / 5 |
| Floor1 tuliplanet | Posted 2005-12-02 17:42 |
| 新手上路 Posts 5 Credits 18 | |
|
If I open a console, no matter what operations I have done in it, I hope to track the operation records and finally write them into a file. For example, I have done the following operations in the console:
C:\>set value=1 C:\>Change_Value.bat C:\>echo 1 1 C:\>set value=2 C:\>echo 2 2 C:\>set value=3 C:\>%value% '3' is not an internal or external command, nor is it a runnable program or batch file. C:\> Then when I exit the console, I want to save all the run commands above in a file, say Command.log. The content recorded in the file is, for example: set value=1 Change_Value.bat echo 1 set value=2 echo 2 set value=3 %value% Is there any good way? The way we are doing now is to write an echo under each command, and then repeat the command above and write it after the echo. This way is very stupid and easy to make mistakes. Please give me some advice, great experts! |
|
| Floor2 无奈何 | Posted 2005-12-02 22:48 |
| 荣誉版主 Posts 356 Credits 1,338 | |
|
Press F7, then copy these commands.
|
|
| Floor3 tuliplanet | Posted 2005-12-05 09:34 |
| 新手上路 Posts 5 Credits 18 | |
|
This still doesn't achieve my purpose! I want to make a bat file, and I want to output all the executed commands after the bat file is executed. But when I put doskey /h at the last line of the bat file, there is nothing output. It seems that the commands in the bat file are not recorded at all. I'm苦恼! Do you guys have any other ways?
|
|
| Floor4 willsort | Posted 2005-12-05 13:48 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re tuliplanet:
A very interesting topic. According to your requirements, I wrote the following BatDump code. It can only dump some simple batch scripts. When encountering some complex batch scripts, there will be many unexpected problems, after all, it is not the normal execution process of a program. In addition, if the batch script to be dumped contains statements like pause that need to accept keyboard input, the selection confirmation needs to be done "in the dark" during the dumping process (the situation in CMD is relatively special). |
|
| Floor5 tuliplanet | Posted 2005-12-05 16:45 |
| 新手上路 Posts 5 Credits 18 | |
|
Hmm~~! The Great Expert's meaning is that you copied all the commands in the bat file into one file, but what we need is to really know which commands were run when the bat file was executed. For example, there are if else statements and goto statements when running, and some branches are not taken. We need to record the running state of the bat, not what's in it. So, experts, see if there are other good ways?
|
|
| Floor6 willsort | Posted 2005-12-05 18:30 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re tuliplanet:
I don't know how you tested my code? Its function is exactly to obtain a sequence of running statements of a batch file, so the text intercepted by it is no longer a strictly batch file. For example, there will only be goto label in this text, and there will be no :label label. |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |