开发者

Accessing Every File on the File System (no matter what) On Windows 7

In c#, on a windows 7 machine, how can I programmatically access every 开发者_JAVA百科file on the file system as though I was a "Master Administrator".

The main priority here, is that after my c# program is installed, that it won't run into any file/folder access permission problems. My program runs as a windows service, and it must allow a user to backup any files on the file system.


I would have thought that it would work if you just make sure that the service runs under an account in the Backup Operator group. I thought that group had access to all files no matter what permissions there are.

Quote from MS Support page:

SID: S-1-5-32-551 Name: Backup Operators Description: A built-in group. By default, the group has no members. Backup Operators can back up and restore all files on a computer, regardless of the permissions that protect those files. Backup Operators also can log on to the computer and shut it down.

Though that page is for earlier versions of Windows so I'm not 100% certain that it's not been changed.


There is the Win32 backup API which is most likely what you want, maybe in combination with the Volume Shadow Service. And your application has to have the SeBackupPrivilege privilege. Note, though, that files encrypted with EFS can be read, but only in their encrypted form.

Links which may also be interesting for you:

http://mutable.net/blog/archive/2006/11/21/an-intelligent-backup-system-for-windows-part-3.aspx

http://msdn.microsoft.com/en-us/library/aa362520(v=VS.85).aspx


You will have to configure the service to run under an account with sufficient privileges.

AFAIK the standard 'Local System' already has rather high privileges. But no matter what, you won't be able to access files that are reserved to the System account, or files that are in use exclusively. Your program will always have to be able to handle Access related exceptions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜