473,396 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Process, ProcessStartInfo fail to run large batch file

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.Stand ardOutput.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
Nov 20 '05 #1
3 2411
* =?Utf-8?B?TGVvIEhlc2th?= <le*******@molex.com> scripsit:
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:


Does it work when using this sample?

<http://www.mvps.org/dotnet/dotnet/samples/miscsamples/downloads/RedirectConsole.zip>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Hi.

We haven't tried using the technique shown in the sample at
http://www.mvps.org/dotnet/dotnet/sa...loads/Redirect
Console.zip, because that technique, involving starting a second thread,
won't do what we want. We want the .NET process to run the batch file,
wait until the batch process is done running, get back control after the
batch process is done, and continue running. Starting a second thread
doesn't do that; the processes would run in parallel.

We could perform the test, but the result (the problem either does or
does not happen when using threads), though interesting, would not be
useful to us.

Regards

Leo Heska
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
* Leo Heska <le*******@molex.com> scripsit:
We haven't tried using the technique shown in the sample at
http://www.mvps.org/dotnet/dotnet/sa...loads/Redirect
Console.zip, because that technique, involving starting a second thread,
won't do what we want. We want the .NET process to run the batch file,
wait until the batch process is done running, get back control after the
batch process is done, and continue running. Starting a second thread
doesn't do that; the processes would run in parallel.


I still don't understand what's the problem? Synchronization using a
Boolean variable should not be a big problem.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Fred Mellender | last post by:
I looked at http://www.codeproject.com/csharp/LaunchProcess.asp?target=process and tried to follow the code there. My code is: public class Test { public ProcessStartInfo StartInfo; public...
0
by: Leo Heska | last post by:
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...
1
by: Bucky Pollard | last post by:
I have a web service that needs to create a batch file and call it (since there are no APIs for the functionality I am looking for). I am using the Process and ProcessStartInfo objects. When I try...
1
by: Bill Rapoza | last post by:
We have a method that executes an arbitrary batch file (we use it for remote upgrades of our system). When we execute this method from outside of ASP.NET (either in the foreground app or from a...
15
by: jcrouse | last post by:
Here is my code: Dim sw As StreamWriter = File.CreateText(Application.StartupPath & "\mameversion.bat") sw.WriteLine(lblMameExePath.Text & " -help >""" & Application.StartupPath &...
6
by: jcrouse | last post by:
This is kind of a continuation of another thread that was somewhat resolved: Well, the dilemma seems to be this. I want to be able to hide the DOS box AND pause the code until execution is...
3
by: Zeya | last post by:
I have created a very simple batch file and trying to retrieve the standard output but everytime I run the code it returns ExitCode as 1. I have created a batch file as simple as ping localhost...
2
by: Bala Nagarajan | last post by:
Hello, I am having issues when i use the Systsem.Diagnostics.Process namespace to start a process. The problem is that i am able to succeed in starting a process (an exe) only few times in a row...
9
by: Eran.Yasso | last post by:
Hi, My app starts process. Some times this process exits because of exception. Can my app know if the process exited due to exception or gracefully? In both ways, the exit code of this...
0
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I started a thread regarding this issue, but now i'm facing new problem, so i'm starting a new thread, hope it's ok... anyway, using my c# windows application, i'm excuting and exe file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.