简体   繁体   English

如何在不需要管理员权限的情况下使用 Inno Setup 在 HKLM 中创建注册表项

[英]How to create registry key in HKLM using Inno Setup without requiring Administrator permissions

I am developing desktop application using C# and creating setup using Inno setup compiler.我正在使用 C# 开发桌面应用程序并使用 Inno setup 编译器创建设置。

Let me explain application functionality,让我解释一下应用程序的功能,

  1. I have created application Setup using Inno Setup all user (ie application can install in admin/non admin PC).我已经使用 Inno Setup 所有用户创建了应用程序安装程序(即应用程序可以安装在管理员/非管理员 PC 中)。

     //all user PrivilegesRequired=lowest
  2. While installing application, I want to create registry key in HKLM .安装应用程序时,我想在HKLM创建注册表项。 For this I have added registry key in Inno Setup script as below为此,我在 Inno Setup 脚本中添加了注册表项,如下所示

    [Registry] Root: HKLM; Subkey: "SOFTWARE\\Wow6432Node\\TestKey"; Permissions: users-modify; \\ Flags: uninsdeletekey createvalueifdoesntexist; ValueType: string; \\ ValueName: "SOAPAddress"; ValueData: "ABC"
  3. While installing application registry key not created its throws below exception安装应用程序注册表项时未创建其抛出以下异常

    --------------------------- Error --------------------------- Error creating registry key: HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\TestKey RegCreateKeyEx failed; code 5. Access is denied. Click Retry to try again, Ignore to proceed anyway, or Abort to cancel installation.

Please help me, How can I create registry key in HKLM using Inno Setup compiler.请帮助我,如何使用 Inno Setup 编译器在HKLM创建注册表项。

I had checked in VS2010 its create registry key but setup can't run non-admin PC.我已经在 VS2010 中检查了它的创建注册表项,但安装程序无法运行非管理员 PC。

Thanks in advance!提前致谢!

You need Administrator privileges to write to HKLM .您需要管理员权限才能写入HKLM So you cannot use the PrivilegesRequired=lowest .所以你不能使用PrivilegesRequired=lowest

And creating an user-writable key in HKLM is a bad practice.HKLM创建用户可写的密钥是一种不好的做法。

You cannot have an installer that can be run by a non-admin user, yet be able to write to HKLM .您不能拥有可以由非管理员用户运行但能够写入HKLM That's a basic principle of Windows security.这是 Windows 安全的基本原则。


It's not really clear what you mean by "application can install in Admin/non admin PC" , but maybe you are actually looking for this:您所说的“应用程序可以安装在管理员/非管理员 PC 中”不是很清楚,但也许您实际上正在寻找这个:
Make Inno Setup installer request privileges elevation only when needed .仅在需要时使 Inno Setup 安装程序请求权限提升

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM