Access denied exception when calling getprocesses
Posted on 2008-11-05
We have an application that works fine 95% of the time for all our customers, however 2 cusotmers are reporting a fatal error "Access Denied"
This following is a sample of the code , the applciation performs this operation for a number of reasons the following is the simplest case, just checking if the current problem is already running on the machine.
Loop through processes on current machine to check that application is only being run by a single user, important if being run on Windows Server
For Each proc As Process In System.Diagnostics.Process.GetProcesses
Check each process name with process name against current process name
If proc.ProcessName = System.Diagnostics.Process.GetCurrentProcess.ProcessName Then
If Process names match and the Process IDs are different then another instance of the application is running
If proc.Id <> System.Diagnostics.Process.GetCurrentProcess.Id Then
MessageBox.Show(System.Diagnostics.Process.GetCurrentProcess.ProcessName + " already Running ")
This is failing on Window 2003 service pack 2 at one of our customers, but the code works fine for us and other customers in the same envirnoment. This is a .NET framework 1.1 solution .
We have checked and double checked that the user has administrator priveleges , still we get the error though, when we comment out the above code and the application continues to the next occurrence of getprocesses.