简体   繁体   English

我在哪里可以放置LOCALMACHINE以外的普通用户数据-没有管理权限的注册表

[英]Where can i place common user data other than LOCALMACHINE -Registry without Administrative Rights

In Windows other than the registry -localmachine where can I place common user data that could be accessed by all users. 在除注册表-localmachine以外的Windows中,我可以在其中放置可由所有用户访问的公共用户数据。

i need to do this without requesting elevation of admin rights 我需要执行此操作而不要求提升管理员权限

You can store it in the Application data folder. 您可以将其存储在“应用程序数据”文件夹中。 which you can get from Envorinment: 您可以从Envorinment获得:

var appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);

To determine if you can access the folder without admin right, run Visual Studio, without admin rights, and see if this code executes successfully. 若要确定是否可以在没有管理员权限的情况下访问该文件夹,请在没有管理员权限的情况下运行Visual Studio,然后查看此代码是否成功执行。

   class Program
    {
        static void Main(string[] args)
        {
            var folder = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);
            var file = Path.Combine(folder, "testfile.txt");

            File.WriteAllText(file, " Test Settings");
            Console.ReadLine();
        }
    }

No such location is available by default. 默认情况下,没有这样的位置。 Regular ( ie , non-administrative users) do not have the requisite privileges to mess with system files or files that belong to other users—that would be a security issue. 普通用户( 非管理用户)没有必要的特权来干扰系统文件或属于其他用户的文件,这将是安全问题。 As such, they would not be able to write to a "common" directory. 因此,他们将无法写入“公用”目录。

If you need all users to be able to write to some type of common area, you need to set it up yourself. 如果您需要所有用户都可以写入某种类型的公共区域,则需要自己进行设置。 Generally, this is done by an installer application. 通常,这是由安装程序应用程序完成的。 The installer application will need to request elevation so that it has administrative privileges in order to write to restricted folders and alter security rights. 安装程序应用程序将需要请求提升权限,以便它具有管理权限,以便写入受限制的文件夹并更改安全权限。 If you're using a standard installer utility, then this is usually a built-in feature. 如果您使用的是标准安装程序实用程序,则通常是内置功能。 If you're writing your own, you arrange for it to have administrative privileges by embedding a manifest with level set to requireElevation (search Stack Overflow for details). 如果你正在写你自己的,你安排它通过嵌入清单与具有管理权限level设置为requireElevation (搜索栈溢出了解详细信息)。

The installer it will create a sub-directory of the common application data folder (the enumerated value Environment.SpecialFolder.CommonApplicationData in the .NET world) for your application's use. 安装程序将创建公用应用程序数据文件夹的子目录(.NET世界中的枚举值Environment.SpecialFolder.CommonApplicationData )供您的应用程序使用。 By default, of course, that sub-directory will inherit the restrictions of its parent folder, so the installer will also need to explicitly set the ACL (access control list) on that sub-directory to grant all users write access. 当然,默认情况下,该子目录将继承其父文件夹的限制,因此安装程序还需要在该子目录上显式设置ACL(访问控制列表),以授予所有用户写访问权限。 This can be done in the .NET Framework using the Directory.SetAccessControl method . 这可以在.NET Framework中使用Directory.SetAccessControl方法完成

Then, after installation is complete, administrative privileges will not be required to run your application. 然后,安装完成后,管理权限将不再需要运行应用程序。 The application can just save into its own sub-directory of the common application data folder, which its installer has ensured that all users have read/write access to. 该应用程序可以保存到公用应用程序数据文件夹的自己的子目录中,其安装程序已确保所有用户对该文件都有读/写访问权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 注册表更改权限删除其他用户权限 - Registry change permission remove other user rights 在未以管理权限运行Outlook的情况下创建邮件 - Create mail where Outlook is not running in Administrative rights 无管理权限的静默卸载msi软件包命令 - silent uninstall msi package command WITHOUT administrative rights 即使用户具有管理权限,App也无法写入注册表 - App is unable to write to the registry, even though the user has administrative privileges Registry.LocalMachine返回null - Registry.LocalMachine returns null 如何通过提示用户输入管理员凭据,将文件复制为Vista中的“标准用户”(即“管理选择应用程序”)? - How can I copy a file as a “Standard User” in Vista (ie “An Administrative Choice Application”) by prompting user for admin credentials? 没有管理员权限我可以保存到哪个存储库? - What repository can I save to without having admin rights? 我可以通过物理访问从管理用户隐藏.NET内存变量吗? - Can I hide a .NET in-memory variable from Administrative user with physical access? Registry.LocalMachine.OpenSubKey()返回null - Registry.LocalMachine.OpenSubKey() returns null 如何读取和写入LocalMachine注册表项 - How to read and write LocalMachine registry keys
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM