locked
System.Diagnostics.Process.Start() failed with return value false RRS feed

  • Question

  • Hi

    I have a windows service which try to start process using System.Diagnostics.Process.Start() method.

    These are only properties which are set before caling Start() method

    StartInfo.FileName
    StartInfo.Arguments 
    StartInfo.WindowStyle

    When I run service under local system account it return false and process is not excuted. If I change account to something else it start working. If I restart server it works also some time with local system account but in some phase start returning false again.

    Process which I try to start shut down automatically if it get executed.

    I t looks that some limit will get exeed and after that it start failing.

    What could be that limit and how to check that?

    Wednesday, November 25, 2015 7:13 PM

Answers

  • Process.Start is just a mean to run unmanaged or legacy code through command prompt.

    if the program is written b4 .NET is even created. u don't expect unmanaged code to return a CLR exception error.

    if the program u executing is a managed code, u should look into appropriate mean to invoke it instead through Process.Start

    and u shouldn't simply grant admin right to local sys account , u are creating a security risk and loophole.

    have u look into the event log - security section?

    it seems to me, u should look at the account using for the window service, can it be change to appropriate account which is tested positively when running that program.


    • Edited by Kelmen Wednesday, December 2, 2015 4:47 AM
    • Proposed as answer by DotNet Wang Thursday, December 3, 2015 8:35 AM
    • Marked as answer by DotNet Wang Monday, December 7, 2015 7:35 AM
    Wednesday, December 2, 2015 4:44 AM

All replies

  • Hi koltti,

    It might be the permission issue of the account/ user. Even though the user has administrator privilege but the account might not be in the admin user group. Try adding the local system account into the local machine admin user group. Hope this helps you.

    Thanks,

    Sabah Shariq

    • Proposed as answer by DotNet Wang Thursday, November 26, 2015 6:32 AM
    • Unproposed as answer by DotNet Wang Friday, November 27, 2015 8:14 AM
    Wednesday, November 25, 2015 7:54 PM
  • Hard to beliew that. It should return exception in that case and restarting server do not change permissions...
    Wednesday, November 25, 2015 8:24 PM
  • Hi koltti,

    Please check whether the file/application is opened before you use Process object to start it.

    As the document said.

    If the process resource specified by the FileName member of the StartInfo property is already running on the computer, no additional process resource is started. Instead, the running process resource is reused and false is returned.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 26, 2015 6:41 AM
  • Hi

    I know what documentation says about it but it not make sense what it is saying comparing to my case.

    There is no process associated to this exe what I trying to start running. As I said if I just change account it start working.

    Thursday, November 26, 2015 3:06 PM
  • Hi koltti,

    Set WorkingDirectory property and try again.

    processInfo.WorkingDirectory = Path.GetDirectoryName(pathOfYourEXE);
    Best Regards,
    Li Wang

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 27, 2015 2:54 AM
  • Hi

    I tried to add  local system account to admin group and setting working directoy.

    Did not help.

    Anyone familiar with Windows performance counter so that if it shows some resource to be end for local system account?

    Or can I switch some internal .net logging on to get more info where in Start() method it fail?

    Friday, November 27, 2015 7:56 AM
  • Hi koltti,

    >>can I switch some internal .net logging on to get more info where in Start() method it fail?

    You could open event viewer to see the detail event log when start method fail.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 30, 2015 5:18 AM
  • Hi

    Nothing in event viewer related to that problem.

    Monday, November 30, 2015 5:25 PM
  • Hi koltti,

    Set RedirectStandardOutput property to true and see the response. Code below is for your reference.

    Process p = new Process();
    p.StartInfo.FileName = "xxx.exe";
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.UseShellExecute = false;
    p.Start();
    string message = p.StandardOutput.ReadToEnd(); 
    p.WaitForExit();
    Best Regards,
    Li Wang

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 1, 2015 8:15 AM
  • Process.Start is just a mean to run unmanaged or legacy code through command prompt.

    if the program is written b4 .NET is even created. u don't expect unmanaged code to return a CLR exception error.

    if the program u executing is a managed code, u should look into appropriate mean to invoke it instead through Process.Start

    and u shouldn't simply grant admin right to local sys account , u are creating a security risk and loophole.

    have u look into the event log - security section?

    it seems to me, u should look at the account using for the window service, can it be change to appropriate account which is tested positively when running that program.


    • Edited by Kelmen Wednesday, December 2, 2015 4:47 AM
    • Proposed as answer by DotNet Wang Thursday, December 3, 2015 8:35 AM
    • Marked as answer by DotNet Wang Monday, December 7, 2015 7:35 AM
    Wednesday, December 2, 2015 4:44 AM