RegSaveKeyEx Requires Elevation?

元气小坏坏 提交于 2020-01-06 12:22:26

问题


I have code that uses Win API function RegSaveKeyEx to save registry entries to a file. However, RegSaveKeyEx returns ERROR_PRIVILEGE_NOT_HELD when run on Win Vista or Win 7. The code enables security privilege SE_BACKUP_NAME using code Microsoft provides in example function SetPrivilege.

Everything works fine on Win XP (admin user) or if I disable UAC on Win Vista or Win 7. Is it not possible to use RegSaveKeyEx on Vista without elevating the process?


回答1:


Standard users do not have SE_BACKUP_NAME privilege, so no, RegSaveKeyEx will not work on Vista without elevation.

Backup is one of the very "dangerous" privileges - it enables you to basically read anything on disk regardless of ACL's.




回答2:


You could give permission the specific user (or group) by going to the following ...

Control Panel->
  Administrative Tools->
    Local Security Policy->
      Local Policies->
        User Rights Assignment-> Back up files and directories (SE_BACKUP_NAME)

... and adding the user (or group) you want. Or you could add the users to Backup Operators.

But, you should be cautious here. See great comment below by Michael.



来源:https://stackoverflow.com/questions/1088612/regsavekeyex-requires-elevation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!