在 Windows 7 上访问文件系统上的每个文件(无论如何)
在 c# 中,在 Windows 7 计算机上,如何以编程方式访问文件系统上的每个文件,就像我是“主管理员”一样。
这里的主要优先事项是,在安装我的 C# 程序后,它不会遇到任何文件/文件夹访问权限问题。我的程序作为 Windows 服务运行,它必须允许用户备份文件系统上的任何文件。
In c#, on a windows 7 machine, how can I programmatically access every 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我本以为只要确保该服务在
Backup Operator
组中的帐户下运行,它就会起作用。我认为该组可以访问所有文件,无论有什么权限。引自 MS 支持页面:
SID:S-1-5-32-551
名称: 备份操作员
描述:一个内置组。默认情况下,该组没有成员。备份操作员可以备份和还原计算机上的所有文件,无论保护这些文件的权限如何。备份操作员还可以登录计算机并将其关闭。
虽然该页面适用于早期版本的 Windows,所以我不能 100% 确定它没有被更改。
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.
有 Win32 备份 API 这很可能是您想要的,也许与 卷影服务。并且您的应用程序必须具有 SeBackupPrivilege 权限 。但请注意,可以读取使用 EFS 加密的文件,但只能读取加密形式。
您可能也感兴趣的链接:
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
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
您必须将服务配置为在具有足够权限的帐户下运行。
AFAIK 标准的“本地系统”已经具有相当高的权限。但无论如何,您将无法访问保留给系统帐户的文件或专用的文件。您的程序必须始终能够处理与 Access 相关的异常。
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.