We can have PowerShell eat an .exe’s STDOUT very easily:
xcopy file.txt target.txt | Out-Null;
We can have it eat both STDOUT and STDERR by redirecting STDERR into STDOUT
xcopy file.txt target.txt 2>&1 | Out-Null;
xcopy “ThisFileDoesn’tExist.ps1” target.txt 2>&1 | Out-Null;
Unix’s filehandles are somewhat clever. You can redirect STDOUT to a file, then redirect STDERR into STDOUT, and eat STDOUT. This nukes STDERR. I’ll leave the advisablity of this to the user.
cp Schroedinger.txt target.txt> found.txt 2>&1 > dev/null
However, this doesn’t work in PowerShell:
xcopy Schroedinger.txt target.txt | Set-Content found.txt 2>&1 | Out-Null
If worst comes to worst, we can use cmd.exe to do this.
cmd /c xcopy Schroedinger.txt target.txt “2>NUL”
Ugh. Anyone have any better ideas?