Wednesday, June 27, 2012

Using SysInternals ProcessExplorer to find the cause of “access denied” error

Often when you try to rebuild your project or even just delete or rename a file, you get the “access denied” error. For example, I run my application from the command line and while it runs I try to rebuild it in Visual Studio:

Such “access denied” issues are also caused by system services like for example name-it-source-control caching service. You just can’t delete your files becase a service locks them.

One of the simplest ways to locate the true culprit – the application or the service which locks the access to the specified file/files – is to use the ProcessExplorer from SysInternals.

In PE, just navigate to Find/Find Handle or DLL. ProcessExplorer will find out and show the list of processes which have active handles to your file:

The example demonstrates the situation described at the beginning – the cause of the access denied to ConsoleApplication55.exe was the ConsoleApplication55.exe process running in the operation system. However, you can expect other valuable findings, like for example the TSVNCache.exe.

No comments: