0

Below is the code for running the batch file from the command prompt. The problem is that there is a pause command in the batch file which is stopping the application and I am not able to proceed with the next step. Can some one give me an idea to fix this.

Process gacCOMprocess = new Process();
infoPageExecuteBatchFiles.PageText = "Running gacCOM.bat ";
infoPageExecuteBatchFiles.Refresh();
ProcessStartInfo gacCOMprocessStartInfo = new ProcessStartInfo();
gacCOMprocessStartInfo.FileName = PRES_TIER_PATH + "\\gacCOM.bat ";
gacCOMprocessStartInfo.UseShellExecute = false;
gacCOMprocessStartInfo.RedirectStandardOutput = true;
gacCOMprocessStartInfo.CreateNoWindow = true;
gacCOMprocessStartInfo.RedirectStandardInput = true;
gacCOMprocess.StartInfo = gacCOMprocessStartInfo;
gacCOMprocess.OutputDataReceived += new DataReceivedEventHandler(ExecuteBatchFilesHandler);
gacCOMprocess.Start();
gacCOMprocess.BeginOutputReadLine();
gacCOMprocess.WaitForExit();
gacCOMprocess.Close();
Otiel
  • 18,404
  • 16
  • 78
  • 126
  • Sending a CRLF over the redirected StandardInput might help. – Heinzi Dec 02 '11 at 08:55
  • 2
    can't you remove the pause manually from the file: gacCOM.bat ? or you clone that file in another one, remove the pause and run the clone. – Davide Piras Dec 02 '11 at 08:56
  • Please see if this is of help http://stackoverflow.com/questions/3583565/how-to-skip-pause-in-batch-file – CodeMad Dec 02 '11 at 09:10

1 Answers1

1

You could just add a parameter that you can pass along with the command line when you start the program. Then add a check for this parameter to each pause. That's what i did recently (assuming you can edit the batch file):

Set IsAutomated=%1

IF NOT %IsAutomated%==1 (
    echo Script was started manually.
    pause
)

That was because the script was still also run manually and in that case, the pause was needed.

Botz3000
  • 39,020
  • 8
  • 103
  • 127