Cocowalla
Cocowalla

Reputation: 14331

How to determine who changed a file?

In Windows, how can I programmatically determine which user account last changed or deleted a file?

I know that setting up object access auditing may be an option, but if I use that I then have the problem of trying to match up audit log entries to specific files... sounds complex and messy! I can't think of any other way, so does anyone either have any tips for this approach or any alternatives?

Upvotes: 4

Views: 3030

Answers (3)

Anders Abel
Anders Abel

Reputation: 69250

You can divide your problem into two parts:

  1. Write to a log whenever a file is accessed.
  2. Parse, filter and present the relevant information of the log.

Of those two part 1, writing to the log is a built in function through auditing as you mention. Reinventing that would be hard and probably never get as good as the builtin functionality.

I would use the built in functionality for logging by setting up an audit ACL on those files. Then I would focus my efforts on providing a good interface that reads the event log, filters out relevant events and presents them in a way that is suitable and relevant for your users.

Upvotes: 4

Grant Peters
Grant Peters

Reputation: 7825

You could always create a file system filter. This might be overkill, but it depends on your purposes. You can have it load at boot and it sits behind pretty much every file access (its what virus scanners usually use to scan files as they are accessed).

Simply need to log the "owner" of the application that is writing to the file.

Also see the MSDN documentation

Upvotes: 3

Jerry
Jerry

Reputation: 4547

The only way I know of to do this is to set up a FileSystemWatcher and keep it running. Oh, and if it's across a network drive, it may randomly lose connection, so it may be good to force a disconnect/reconnect every few hours just to make sure it has a fresh connection.

Upvotes: 0

Related Questions