设置“RUNASADMIN"Inno Setup 中的应用程序兼容性标志 [英] Set "RUNASADMIN" application compatibility flag in Inno Setup
问题描述
我的应用程序是用 Java 制作的,它需要管理员权限才能在 Windows 上运行.使用 Inno Setup,我可以使用以下代码更改注册表,它适用于 Windows 7,但对于 Windows 10 和 8,我没有同样的成功,因为注册表显然不再存在.
My application was made with Java and it needs Administrator privilege to run on Windows. Using Inno Setup I could change change a registry with the following code and it works just fine for Windows 7, however for Windows 10 and 8, I don't have the same success, since the registry apparently doesn't exist anymore.
[Registry]
Root: HKCR; Subkey: "SOFTWAREMicrosoftWindows NTCurrentVersionAppCompatFlagsLayers"; ValueType: String; ValueName: "{app}AppExecutable.exe"; ValueData: "RUNASADMIN"; Flags: uninsdeletekeyifempty uninsdeletevalue;
Root: HKLM; Subkey: "SOFTWAREMicrosoftWindows NTCurrentVersionAppCompatFlagsLayers"; ValueType: String; ValueName: "{app}AppExecutable.exe"; ValueData: "RUNASADMIN"; Flags: uninsdeletekeyifempty uninsdeletevalue;
我读到它可以用可执行清单来完成,但我想它只适用于 Visual Studio 制作的应用程序,这不是我的场景.有没有办法把它放在 Java 清单中?
I read it can be done with the executable manifest, but I suppose it is only for applications made by Visual Studio, which is not my scenario. Is there a way to put it in a Java manifest?
我想知道我是否可以通过其他方式执行此操作,是否有其他注册表可以修改,或者我是否必须在安装期间附加并运行其他类型的脚本.
I would like to know if I can do this in some other way, if there is another registry I can modify or if I have to attach and run another kind of script during my instalation.
推荐答案
我认为您的问题与 Windows 7 和 Windows 8/10 无关.而是你的 Windows 7 是 32 位,而 Windows 8/10 是 64 位.
I do not think your problem is related to Windows 7 vs. Windows 8/10. It's rather that your Windows 7 is 32-bit and Windows 8/10 is 64-bit.
Inno Setup 安装程序是 32 位应用程序,因此默认情况下 SOFTWARE
会重定向到 SOFTWAREWow6432Node
.
The Inno Setup installer is 32-bit application, so SOFTWARE
gets redirected to SOFTWAREWow6432Node
by default.
您必须使用显式 64 位注册表根,例如 Root: HKLM64
才能显式避免重定向.
You have to use an explicit 64-bit registry root like Root: HKLM64
to explicitly avoid the redirection.
您可能还需要添加 Check: IsWin64
以确保不会在 32 位安装上处理该条目,因为它会导致错误.
You will probably also want to add Check: IsWin64
to make sure the entry is not processed on 32-bit installations, as it would cause an error.
请参阅 [Registry]
部分文档.
See [Registry]
section documentation.
我也认为不应该是HKCR
,而是HKCU
.
请参阅为什么不建议在 Inno Setup 中使用 HKCR 注册表根密钥?
I also believe that it should not be HKCR
, but HKCU
.
See Why is it not recommended to use HKCR registry root key in Inno Setup?
[Registry]
; keys for 32-bit systems
Root: HKCU32;
Subkey: "SOFTWAREMicrosoftWindows NTCurrentVersionAppCompatFlagsLayers";
ValueType: String; ValueName: "{app}AppExecutable.exe"; ValueData: "RUNASADMIN";
Flags: uninsdeletekeyifempty uninsdeletevalue; Check: not IsWin64
Root: HKLM32;
Subkey: "SOFTWAREMicrosoftWindows NTCurrentVersionAppCompatFlagsLayers";
ValueType: String; ValueName: "{app}AppExecutable.exe"; ValueData: "RUNASADMIN";
Flags: uninsdeletekeyifempty uninsdeletevalue; Check: not IsWin64
; keys for 64-bit systems
Root: HKCU64;
Subkey: "SOFTWAREMicrosoftWindows NTCurrentVersionAppCompatFlagsLayers";
ValueType: String; ValueName: "{app}AppExecutable.exe"; ValueData: "RUNASADMIN";
Flags: uninsdeletekeyifempty uninsdeletevalue; Check: IsWin64
Root: HKLM64;
Subkey: "SOFTWAREMicrosoftWindows NTCurrentVersionAppCompatFlagsLayers";
ValueType: String; ValueName: "{app}AppExecutable.exe"; ValueData: "RUNASADMIN";
Flags: uninsdeletekeyifempty uninsdeletevalue; Check: IsWin64
这篇关于设置“RUNASADMIN"Inno Setup 中的应用程序兼容性标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!