out to screen and file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Posts: 1
Joined: 06 Dec 2020 20:52

out to screen and file

#1 Post by dosW10 » 06 Dec 2020 21:00

Got a batch file that launches a DOS app that requires user to enter some integers and press some keys. it output everything to console screen only. like it as well to output/append to file as well. Everything that shows up on the screen to get dumped and append to a file additionally. i tried something from google but did not help.

Posts: 88
Joined: 19 Jul 2015 02:27
Location: Philippines

Re: out to screen and file

#2 Post by Meerkat » 07 Dec 2020 09:50

Hmm... I'm no expert, but I think you need to "duplicate" your commands like the yourcode label below. The ECHO is easy, but the SET/P is a bit complicated, just so that what you see in CMD is basically what you see at file output (in this case, file.txt).

Code: Select all

@echo off
rem 5 is arbitrary (but do not use 1 or 2, (or 3 maybe))
call :yourcode 5>"file.txt"
exit /b 0

rem you main code here...

rem the next line just outputs "input: " w/o newline.
<nul set /p "=input: "
set /p "var=input: ">&5
rem NOTE: the actual typedwritten user input will NOT be
rem displayed in file, so the next line will write it in file.

echo(press any key to exit
echo(press any key to exit>&5
goto :eof

Posts: 4043
Joined: 22 Jan 2010 18:01
Location: Germany

Re: out to screen and file

#3 Post by aGerman » 07 Dec 2020 11:01

It's difficult to answer questions without seeing any question mark.
like it as well to output/append to file as well
I suspect the keyword is "TEE" here.
There are batch scripts like that ...
... as well as a couple of 3rd party TEE tools that you'll find in the net.
enter some integers and press some keys
If you want to automate this too, then you will probably have to use another language (e.g. AutoIt). Depending on the app that you're talking about you might have the possibility to pass parameters containing the values that you have to enter elsewise. Other tools may accept piped input. Hard to say without even knowing the name of this app...


Post Reply