>* ---------------------------------------------------------------------- >* Run the command >* ---------------------------------------------------------------------- >This.poWshScriptExec = This.poShell.Exec( tcCMD ) > >* ---------------------------------------------------------------------- >* Read the output of the shell command thread (STDERR) >* ---------------------------------------------------------------------- >DO WHILE This.poWshScriptExec.StdErr.AtEndOfStream = .F. > lcString = This.poWshScriptExec.StdErr.ReadLine() > > IF EMPTY( lcString ) = .F. > lcStdErr = lcStdErr + lcString + CARET_CHAR > ENDIF > WAIT '' TIMEOUT .1 >ENDDO > >* ---------------------------------------------------------------------- >* Read the output of the shell command thread (STDOUT) >* ---------------------------------------------------------------------- >DO WHILE This.poWshScriptExec.StdOut.AtEndOfStream = .F. > lcString = This.poWshScriptExec.StdOut.ReadLine() > > IF EMPTY( lcString ) = .F. > lcStdOut = lcStdOut + lcString + CARET_CHAR > ENDIF > WAIT '' TIMEOUT .1 >ENDDO > >* ---------------------------------------------------------------------- >* Check to see if the command is still running. >* ---------------------------------------------------------------------- >DO WHILE This.poWshScriptExec.Status = 0 > WAIT WINDOW '' TIMEOUT .1 >ENDDO > >lcRetValBuff = IIF( OCCURS( VCS_ERROR_ID_STR, lcStdErr ) = 0, ALLTRIM( STR( This.poWshScriptExec.ExitCode )), ALLTRIM( STR( VCS_FAILURE ))) + PIPE_CHAR >lcRetValBuff = lcRetValBuff + lcStdErr + PIPE_CHAR + lcStdOut > >RETURN lcRetValBuff >There is some good info at http://support.microsoft.com/kb/960246
DO WHILE This.poWshScriptExec.StdErr.AtEndOfStream = .F. ; OR This.poWshScriptExec.StdOut.AtEndOfStream = .F. * Read from StdErr ... * Read from StdOut ... * At this point your code would * WAIT '' TIMEOUT .1 * I'm not sure that's a good idea. If the batch file writes more than 4K in less than 0.1 seconds * you might overflow as well. * For test purposes, you could try it with no wait at all. * If you want to play nicely with other processes on the same box, you could just issue * DOEVENTS ENDDO