Turns out I made example code for someone in the nsis IRC channel a long time ago to handle this

Comparing Instructor's code with mine and my notes, you should call GetStdHandle first, then AttachConsole, and use the built in FileWrite command and not WriteConsole, if you do this, you can use pipes and redirection (foo.exe > out.txt etc.) still limited to XP and up