CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2008
    Posts
    4

    System.Diagnostics.Process

    Hi,

    I have problem thats been driving me crazy lately,
    I use the following code as a part of a larger application:

    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.EnableRaisingEvents = false;
    proc.StartInfo.FileName = sFileName;
    proc.StartInfo.WorkingDirectory = sWorkingDirectory;
    proc.Start();

    its supposed to be activating an exe file.
    On 90% of the computers I installed it on, it works perfectly.
    on the other 10% nothing happens...I mean absolutly nothing...
    no error message no exception, nothing (I tried pretty much any variation that can create an error should the proccess fails to start, but nothing...)

    has anyone encountered such behaviour before?

  2. #2
    Join Date
    Sep 2007
    Posts
    82

    Re: System.Diagnostics.Process

    That is a weird error. There are no errors being thrown or are you just not catching any errors that could possibly not stop runtime. My first thought is if you have permissions those 10% of machines to start and run a process.

  3. #3
    Join Date
    Sep 2004
    Posts
    1,361

    Re: System.Diagnostics.Process

    How do you find out what sFileName is? Ill give you a clear example of how this can be messed up if it is hard coded.

    I download your program twice and the 2nd version is MyApp[1].exe. Or perhaps, I just download it as something else.

  4. #4
    Join Date
    Feb 2008
    Posts
    4

    Re: System.Diagnostics.Process

    Quote Originally Posted by zdavis
    That is a weird error. There are no errors being thrown or are you just not catching any errors that could possibly not stop runtime. My first thought is if you have permissions those 10% of machines to start and run a process.

    I am trying to catch the errors using try-catch block but nothing is thrown,
    actually I know that the Start() method actually returns True as if everything is ok (I tried chceking the return value from it).

    My guess is also that this is some bizare permission issue, but I cant put my finger on it...I verified that thoese users have admin. priveleges on their computers, I tried checking proccess counters (just in case) but no good came out of it.

    at this point any idea will be a good one...

  5. #5
    Join Date
    Aug 2002
    Location
    ireland
    Posts
    291

    Re: System.Diagnostics.Process

    Have a look in the EventLog on the machines that fail.
    start->control panel->Administrative Tools->Event Viewer.

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: System.Diagnostics.Process

    Add a few Debug.WriteLine calls to your code to display the sFileName and sWorkingDirectory to the debug port.

    Then copy a debug version of your application over to the machine that it's failing on.

    Start up Debug View on the machine and then run your program.

    The debug spew will appear in the Debug View program.

  7. #7
    Join Date
    Sep 2004
    Posts
    1,361

    Re: System.Diagnostics.Process

    If the error is thrown in another thread, your try-catch will not capture it. You need to put one in each thread if you want to catch exceptions that they throw.

  8. #8
    Join Date
    Sep 2007
    Posts
    82

    Re: System.Diagnostics.Process

    can you actually start the process manually on those 10% of machines. Actually start the process without having to use code. If it doesn't start I would think it is something outside the bounds of your code and would most likely point to a permission error or something of the sort.

    -zd

  9. #9
    Join Date
    Feb 2008
    Posts
    4

    Re: System.Diagnostics.Process

    Quote Originally Posted by zdavis
    can you actually start the process manually on those 10% of machines. Actually start the process without having to use code. If it doesn't start I would think it is something outside the bounds of your code and would most likely point to a permission error or something of the sort.

    -zd
    yes, I can start the exe file manually on those PC's.

  10. #10
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: System.Diagnostics.Process

    Try the debugging technique I suggested earlier.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured