Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? suppress stderr with @execstr

Dec
73
1
The @execstr function grabs a line from the stdout stream, but the stderr is still echo'ed to the console. I have not found a way to suppress it, like @execstr[cmd.exe 2>nul] or @execstr[cmd.exe] 2>nul ... any hints?

... replying to myself: The hint is to watch your setdos, doh.
 
Last edited:
Have you tried parentheses?
( do stuff with %@execstr[cmd.exe] ) >&>nul:
 
Both your examples seem to start an interactive CMD. Is that when you want? Regardless, it seems to work here. Compare:
Code:
v:\> echo %@execstr[cmd.exe]
dir xxxxx
File Not Found
exit
Microsoft Windows [Version 6.1.7601] <===== from @EXECSTR

v:\> echo %@execstr[cmd.exe 2>nul]
dir xxxxx
exit
Microsoft Windows [Version 6.1.7601] <===== from @EXECSTR

Likewise with a transient CMD.

Code:
v:\> echo %@execstr[cmd.exe /c dir xxxxx]
File Not Found
 Volume in drive V is DATA <===== from @EXECSTR

v:\> echo %@execstr[cmd.exe /c dir xxxxx 2>nul]
 Volume in drive V is DATA <===== from @EXECSTR
 
Regardless, it seems to work here.

/me doing Darth-Vader "Nooooooooooooooo!" ... I had used setdos /x-6, that's why it ignored the redirection. Doh, sorry for taking your time, I simply got confused by all these setdos commands necessary to get anything done - yes, I know, it's not jpsoft's fault but of the underlying microsoft shell system.
 
Back
Top