Access denied exception when calling getprocesses

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 ")
                      Exit Sub
        End If            
    End If            
Next

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.



ZAKHurstAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ASliborskyCommented:
Check, may be it's just Code Access Security (CAS) exception  - user may have rights, but .NET CLR prevents some code from running if code has no appropriate permissions (Read corresponding section in MSDN - http://msdn.microsoft.com/en-us/library/930b76w0(VS.71).aspx and http://msdn.microsoft.com/en-us/library/aa302424.aspx).

You can check whether code has necessary permnissions by calling Demand, or bypass such checks by calling Assert on permission sobjects.

Also, you can set Full Trust permissions to your application to avoid these checks.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
OS Security

From novice to tech pro — start learning today.