Process, ProcessStartInfo fail to run large batch file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I haven't seen the following problem mentioned anywhere

We have an application written in VB.NET which executes a batch file (named startJob.cmd). We have discovered that if that batch file is too big, the last lines of the batch file will not run. For example, the following one-line batch file runs just fine when invoked from our VB.NET app

echo %PATH% > c:\com\molex\plot\wmIntegration\logs\p0.lo

but the following batch file fails when identically invoked by the same app

REM This is a test This is a test This is a test This is a test This is a test
REM This is a test This is a test This is a test This is a test This is a test
[40 more of these remark lines
echo %PATH% > c:\com\molex\plot\wmIntegration\logs\p0.lo

I am able to reproduce this error 100% of the time on two separate machines, both of which run Windows 2000 server

I doubt that this problem is related either to environment space or total RAM available to the program, because nothing in the above batch file should use up any environment space, or more than a trivial amount of memory. Also, on one of the machines, I tried setting the following in the file c:\WINNT\System32\CONFIG.NT

shell=%SystemRoot%\system32\command.com e:1638

Adding the above line did not affect the problem

Here is the chunk of code which seems most relevant

Protected Overridable Function ExportFileWorkManager() As Boolea
Dim sCmdShell As Strin
Dim oProcess As Proces
Dim oStartInfo As ProcessStartInf
Dim oProcessMonitor As ProcessMonito

'java program hangs(?) or takes long time when these do not have setting
If moJobQueue.DOC_CLASS_NAME = Nothing Or moJobQueue.PROGRAM_NAME = Nothing The
Return Fals
End I

Tr
oStartInfo = New ProcessStartInfo(moConfig.WorkManagerExePath
oStartInfo.Arguments = "export_native @1 @2".Replace("@1", moJobQueue.DOC_ELID).Replace("@2", moJobQueue.PROGRAM_NAME
goLog.LogEntry("IPlot", "ExportFileWorkManager", oStartInfo.Arguments
oStartInfo.CreateNoWindow = Fals
'oStartInfo.RedirectStandardOutput = Tru
oStartInfo.UseShellExecute = Fals
oStartInfo.WindowStyle = ProcessWindowStyle.Norma

'sCmdShell = Quote(moConfig.WorkManagerExePath) & " export_native @1 @2
'sCmdShell = Replace(sCmdShell, "@1", moJobQueue.DOC_ELID
'sCmdShell = Replace(sCmdShell, "@2", moJobQueue.PROGRAM_NAME

oProcess = New Process(
oProcess.StartInfo = oStartInf

'Shell(sCmdShell, AppWinStyle.Hide, True
oProcess.Start(
oProcessMonitor = New ProcessMonitor("java"
oProcessMonitor.Start(
oProcess.WaitForExit(
'System.Diagnostics.Debug.WriteLine(oProcess.StandardOutput.ReadToEnd
'Dim sValue As String = oProcess.StandardOutput.ReadToEn
oProcess.Dispose(
oProcessMonitor = Nothin
Catc
Return Fals
End Tr

'check to make sure our export is there ..
If FileExists(msExportFileName) = False The
Return Fals
End I

Return Tru
End Function 'export the workmanager fil

It looks very much like somehow, internally to .NET, the .cmd file is getting stored in a buffer with maximum size around 1000 bytes. When the file is bigger, it gets truncated

I'm hoping someone from Microsoft can look in to this problem

Thank
 
My code looks very similar to the code above
It is not the size of the BAT being run that makes a difference however, it is the size of the output
Using this bit of code

proc.start(me.startinfo
If Not proc.WaitForExit(Timeout) The
proc.Kill(
strOutput = proc.StandardOutput.ReadToEn
Els

If the process standard output is more than about 2000 characters, it does not exit properly, has to be killed
**It seems to hang because the StandardOutput buffer is full*
If I run the following code instead, the process finishes no matter how big the output

proc.start(me.startinfo
strOutput = proc.StandardOutput.ReadToEn

However, this second option does not protect me should the child process hang for some other reason.
 
Back
Top