cwrea
asked on
How to redirect stderr to file using CMD.EXE and Shell() in VB?
I've got an app where I am calling the VB Shell function to execute a command. In order to capture the command's output, I've actually got it running with "CMD /C myprog.exe >myprog.out" ... now that works fine usually and I get the result of the execution in the file myprog.out
However when something goes wrong, the errors the program writes don't go into the file. In C parlance, it looks like it is writing to stderr in exceptional circumstances.
How can I redirect that output as well to a file? Under UNIX I could specifically tell it to output a particular file number such as stderr; any way to do that with CMD.EXE under NT?
Thanks
However when something goes wrong, the errors the program writes don't go into the file. In C parlance, it looks like it is writing to stderr in exceptional circumstances.
How can I redirect that output as well to a file? Under UNIX I could specifically tell it to output a particular file number such as stderr; any way to do that with CMD.EXE under NT?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Works much easier.... :-)
As in UNIX you just must redirect "stderr" ot "stdout"
"CMD.EXE /C myprog.exe > myprog.out 2>&1"
Yes :-) this works under Windows NT as well *smile* but most people don't know it.
The CMD.EXE has some powerful features starting from Windows 2000/XP.
OK, they don't have the power of a BASH shell but you can do a lot believe me :-)
As in UNIX you just must redirect "stderr" ot "stdout"
"CMD.EXE /C myprog.exe > myprog.out 2>&1"
Yes :-) this works under Windows NT as well *smile* but most people don't know it.
The CMD.EXE has some powerful features starting from Windows 2000/XP.
OK, they don't have the power of a BASH shell but you can do a lot believe me :-)
ASKER