System.Diagnostics.Process not working !! please help
- From: "Nurit N" <NuritN@xxxxxxxxxxxx>
- Date: Thu, 5 Jan 2006 11:37:47 +0200
This is the third newsgroup that I'm posting my problem.
I'm sorry for the multiple posts but the matter becoming urgent.
I hope this is the right place for it...
I have created a very simple batch file (echo hello world) and was trying to
retrieve the standard output but every time I run the code it returns
ExitCode as 1.
The batch file runs just fine from command line.
There is no Win32Exception (no ERROR_FILE_NOT_FOUND and no
ERROR_ACCESS_DENIED)
Also strOutput and strError returns empty.
What ExitCode1 means?
Am I missing on something?
Here is the code:
try
{
System.Diagnostics.Process MFGProc = new System.Diagnostics.Process();
MFGProc.StartInfo.FileName = strMfgWorkDir + strMfgBatFile;
MFGProc.StartInfo.WorkingDirectory = strMfgWorkDir;
MFGProc.StartInfo.UseShellExecute = false;
MFGProc.StartInfo.RedirectStandardError = true;
MFGProc.StartInfo.RedirectStandardOutput = true;
MFGProc.Start();
string strOutput = MFGProc.StandardOutput.ReadToEnd();
string strError = MFGProc.StandardError.ReadToEnd();
MFGProc.WaitForExit();
if (MFGProc.ExitCode == 0)
{
Ok = true;
}
else
{
strErrorMsg = " Running failed. Description: " + strError;
}
}
catch (Win32Exception e)
{
strErrorMsg = "W32 Error:" + e.NativeErrorCode.ToString() + "." +
e.Message ;
}
catch (Exception err)
{
// Process other errors here
strErrorMsg = ("RunMFGCimSession Other error. ErrorMessage: " +
err.Message );
}
Thanks
Nurit
.
- Follow-Ups:
- Re: System.Diagnostics.Process not working !! please help
- From: Abubakar
- Re: System.Diagnostics.Process not working !! please help
- Prev by Date: Browser to destkop app - suggestions
- Next by Date: Re: Getting users from a specifc AD group
- Previous by thread: Browser to destkop app - suggestions
- Next by thread: Re: System.Diagnostics.Process not working !! please help
- Index(es):