For reference, see the source code for this small program, EndPointController.exe: http://www.daveamenta.com/2011-05/programmatically-or-command-line-change-the-default-sound-playback-device-in-windows-7/
Basically, it is a Visual Studio C++ program that is using a printf
function to write information to a command shell window.
Here's an example of me running the program on Windows 7 x64 (using the provided compiled binary from the above link):
C:\Users\James\Desktop>EndPointController.exe
Audio Device 0: Speakers (High Definition Audio Device)
Audio Device 1: AMD HDMI Output (AMD High Definition Audio Device)
Audio Device 2: Digital Audio (S/PDIF) (High Definition Audio Device)
Audio Device 3: Digital Audio (S/PDIF) (High Definition Audio Device)
C:\Users\James\Desktop>
This works perfectly. Now, I'll try to redirect the output to a file:
C:\Users\James\Desktop>EndPointController.exe > test.txt
C:\Users\James\Desktop>type test.txt
C:\Users\James\Desktop>
It didn't work; test.txt
is empty. Is it a permissions issue?
C:\Users\James\Desktop>dir > test.txt
C:\Users\James\Desktop>type test.txt
Volume in drive C has no label.
Volume Serial Number is 16EC-AE63
Directory of C:\Users\James\Desktop
04/20/2014 03:11 AM <DIR> .
04/20/2014 03:11 AM <DIR> ..
05/31/2011 06:16 PM 7,168 EndPointController.exe
04/20/2014 03:12 AM 0 test.txt
2 File(s) 7,168 bytes
3 Dir(s) 171,347,292,160 bytes free
C:\Users\James\Desktop>
No, it does not seem to be a permissions issue. Can anyone explain how this printf
function is somehow circumventing the standard out redirection process?