如何保持对一个bat文件的视频输出设置输出日志后? [英] How do I keep visual output on a bat file after setting up an output log?
问题描述
我运行一个bat文件做一个备份。我把它加入到这个bat文件的顶部。(这是我从本网站上的答案了)
I'm running a bat file to do a backup. I have it set to create a log file of the process by adding this to the top of the bat file.. (which I got from an answer on this site)
@Echo off
SET LOGFILE=MyLogFile.txt
call :Logit >> %LOGFILE%
exit /b 0
现在,我想的bat文件直观地运行它以前一样。我需要最终用户能够看到它在做什么,并在该bat文件菜单作出选择。然而,这code到明显创建日志重新将所有文本日志文件。
Now, I'd like the bat file to visually run the same it was before. I need the end user to be able to see what it's doing and make choices at menus in the bat file. However, this code to create the log obviously re-directs all that text to the log file.
所以,我得到的只是一个启动菜单,询问用户选择做什么和一个日志文件,然后别无其他。
So, I get a log file that just starts with a menu asking the user to choose what to do and then nothing else.
我该怎么做,所以我让我的日志文件,而且屏幕上的输出,为用户?
How do I do it so I get my log file but also the on-screen output for the user?
在此先感谢!
推荐答案
尝试这样的:
@Echo off
SET LOGFILE=MyLogFile.txt
call :Logit
call :Logit >> %LOGFILE%
exit /b 0
:Logit
ping www.google.com
或像这样的:
@Echo off
SET LOGFILE=MyLogFile.txt
call :Logit & call :Logit >> %LOGFILE% & Start %LOGFILE%
exit /b 0
:Logit
ping www.google.com
这篇关于如何保持对一个bat文件的视频输出设置输出日志后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!