Quote:
Originally Posted by @ruantec
Your code is fine and the reason for the exception is quite obvious too... if you check the pic on my post #30 i showed you how to explore your objects so you can debug your code and check your array of processes. if you check few of the array items you will notice that under the main module and in other areas the access is restricted and for that reason you´re getting that exception.
a simple:
Code:
Try
{
//Your code
}
Catch{}
should do the trick for now.. there are other ways but probably too complicated for you atm.
|
Lol you didn't lie when you said that the other ways are too complicated for me xD
Anyway...just 3 days ago I wrote the sample code which was supposed to end the process called "notepad.exe".When I would execute the button click event,the process would not end.However if instead of the "notepad.exe" I write "notepad" then the process ends.Here is the code:
string processName="notepad";
Process[] procs=Process.GetProcessesByName(processName);
foreach(Process process in procs)
{
process.Kill();
}
And just now few minutes ago I was crashing my head by thinking why the hell "notepad.exe" is not found by it's name.And then I remember the modules you mentioned.And finally after 30 minutes of trying,I wrote the code which successfuly ends "notepad.exe" or any other process.
In the bellow example,I wrote the code so that the user can write his own process name which he/she wants to end.Take a look at the image and tell me if this is ok:
__________________
GOODBYE FOREVER EVERYONE...