Capture DOS Output with VB (don't use > like "command.exe > log.txt") - Is it possible?
Posted on 2009-04-30
I'm in need of capturing DOS output, and relaying it into a log file, via VB.
Unfortunately, the program I'm using is PSExec, and although it works directly at the command prompt, by doing a "psexec.exe -s -c -f \\machinename \\servername\share\command.exe >> logfile.txt 2>&1" - I'm running this command from a vb Shell, and it drops the carrots for the logfile completely.
I'm calling on PSExec from within an MS Access DB Form. PSExec gets executed as expected, but unfortunately - I'm in some serious need to be able to log if it's successful or not.
Is it possible to redirect the output of a DOS session to a text file, versus the standard Monitor output using VB?
I've searched quite ab it on this topic, and haven't found much info. Although, I did catch a forum at some point that there was a PERL programmer that had run into the exact same problem with PSExec not logging anything if it's run from a script. - Although in that thread, there didn't appear to be a solution for the PERL gentlemen.
Also, please note that dropping PSExec into a batch file and calling the batch isn't an option at this point, I can only plan on having it called from within the VB itself (as the DB contains about a gazillion and a half different records, etc. on which to call PSExec.)
Any help that can be provided would be greatly appreciated, and as always - thanks for helping.