[SOLVED] Console output to text file missing entries.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
PAB
Posts: 139
Joined: 12 Aug 2019 13:57

[SOLVED] Console output to text file missing entries.

#1 Post by PAB » 03 Aug 2020 13:17

Good evening everyone.

I have this cmd . . .

Code: Select all

for /f "tokens=*" %%i in ('wevtutil.exe el') do echo "%%i" & wevtutil.exe cl "%%i" & wevtutil.exe cl System
When I run it, it outputs the list and any ERRORS to the console, great so far!

I put that in a separate .bat file and called it from another .bat file because I just wanted to create a .txt file on the desktop rather than having it run in the console . . .

Code: Select all

call "%~dp0bin\Events.bat" > "%userprofile%\desktop\Event.txt"
The .txt file is great, EXCEPT the errors are shown on the screen [ ONLY the errors btw ], but NOT in the .txt file.
I added 2>nul to stop the errors showing in the console, but they still don't show in the .txt file.

I basically want everything that gets output to the console as per the first piece of code, including the errors, output to a .txt file.

Thanks in advance.
Last edited by PAB on 03 Aug 2020 17:54, edited 1 time in total.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Console output to text file missing entries.

#2 Post by Squashman » 03 Aug 2020 13:26

The basic syntax to append STDOUT and STDERR to a file.
command >> file 2>&1

PAB
Posts: 139
Joined: 12 Aug 2019 13:57

Re: Console output to text file missing entries.

#3 Post by PAB » 03 Aug 2020 17:54

Squashman wrote:
03 Aug 2020 13:26
The basic syntax to append STDOUT and STDERR to a file.
command >> file 2>&1
Brilliant, thank you, it is appreciated!

Post Reply