19 July 2012

Checking Which User Account is Accessing a File

It's often useful to find out which account is accessing a file, e.g. a CRM Plugin in writing to a log file and you need to determine which Windows account is trying to access the file (in this example it will be the user that the CRM Asynchronous service is running under).

Here's a quick how-to to easily find out this information:

1. Download Process Monitor from Technet, unzip it, and run Procmon.exe
2. Select File and uncheck Capture Events
3. Select Edit --> Clear Display
3. Select Filter --> Filter
4. Under "Display entries matching these conditions:" select the following:
  • Path
  • is
  • [path and filename of the file to monitor]
5. Click Add
6. Click OK
7. Select File and check Capture Events
8. Run the code that will attempt to access the file
9. Go back to Process Monitor and select File and uncheck Capture Events
10. In the events list there will be rows showing the filename, double click on one these
11. From the Event Properties window select the Process tab
12.The user that attempted to access the file is shown.