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?
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.
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.
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...
Re: System.Diagnostics.Process
Have a look in the EventLog on the machines that fail.
start->control panel->Administrative Tools->Event Viewer.
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.
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.
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
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.
Re: System.Diagnostics.Process
Try the debugging technique I suggested earlier.