Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WshScriptExec.Exec
Message
De
23/05/2013 19:33:20
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
WshScriptExec.Exec
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Application:
Desktop
Divers
Thread ID:
01574611
Message ID:
01574611
Vues:
54
Anyone have some input on this? I'm trying to run a batch file using the WScript.Shell.Exec command. The issue I'm having is that the batch file writes a good amount of data to STDOUT/STDERR and it appears to be filling up its buffer and hanging. I've read somewhere that each invocation gets a 4K buffer for STDOUT/STDERR. This is the code that I'm using to read from the two streams. Is there a way for me to capture data from the stream so that it doesn't reach the 4k limit?

When I change the batch file to limit its output it runs without issue.

This is my code but it obviously needs to be modified.

Thanks in advance for you help and ideas.
* ----------------------------------------------------------------------
* 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
Bruce Crane
Software Engineer
Regulus Integrated Solutions, LLC - Napa
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform