Can't CLS during redirection - New bug or known?
Posted: 21 Jan 2023 00:10
Not something I've encountered before, but found myself wanting to clear the screen between outputs during a redirected block, and CLS wouldn't work.
I did a bit of searching, couldn't find mention of the problem here previously.
I believe the issue only occurs if it's STDOUT being redirected.
Flipping the STDERR / STDOUT streams and Redirecting the STDERR handle resolves the issue
I did a bit of searching, couldn't find mention of the problem here previously.
I believe the issue only occurs if it's STDOUT being redirected.
Flipping the STDERR / STDOUT streams and Redirecting the STDERR handle resolves the issue
Code: Select all
@Echo off
1>"%~dp0example.tmp" (
1>con Echo(See this?
Echo(Can't see this, it's in the file
CLS
1>con Echo(Shouldn't see that but do.
)
Pause
1>&2 2>>"%~dp0example.tmp" (
2>con Echo(You won't see this.
CLS
1>&2 Echo(This will go to file
2>con Echo(You Didn't see that.
)
Title close notepad to quit
notepad "%~dp0example.tmp"
Del "%~dp0example.tmp"