Starting process (one console application from another)

2

Does anyone knows why I'm getting this error (not every time but sometimes) when trying to start one console application from another. Error:

System.ComponentModel.Win32Exception (0x80004005): Unknown error (0xfffffffe) at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start()

this is my Code:

System.Diagnostics.Process myProc = new System.Diagnostics.Process();
try
{
    myProc.StartInfo.FileName = @"C:\MyFolder\MyExecutableApplication.exe";
    myProc.Start();
    myProc.WaitForExit();
    procesResult = myProc.ExitCode;
}
catch (Exception ex)
{
    cLog.WriteLog("problem", ex.ToString(), myConfig.LogPath);
}
finally
{
    if (myProc != null)
    {
        myProc.Close();
    }
}

Thank you

c#
visual-studio-2010
asked on Stack Overflow May 4, 2012 by Avicena00 • edited May 4, 2012 by digEmAll

3 Answers

3

I guess it's the permission problem. Try this

myProc.StartInfo.UseShellExecute = false;
myProc.StartInfo.RedirectStandardOutput = true;
myProc.StartInfo.RedirectStandardError = true;

reference from this comments

answered on Stack Overflow May 4, 2012 by fankt
0

It seems like an permission elevation problem(although I do not know the reason you get the error sometimes); try adding;

myProc.StartInfo.Verb = "runas";
answered on Stack Overflow May 4, 2012 by daryal
0

I faced with the same issue. Try to turn off UAC and add exception to windows defender (or another security tool)

answered on Stack Overflow May 23, 2017 by burzhuy

User contributions licensed under CC BY-SA 3.0