将“ RUNASADMIN”设置为Inno Setup中的应用程序兼容性标志 [英] Set "RUNASADMIN" application compatibility flag in Inno Setup

查看:363
本文介绍了将“ RUNASADMIN”设置为Inno Setup中的应用程序兼容性标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序是使用Java制作的,并且需要管理员权限才能在Windows上运行。使用Inno Setup,我可以使用以下代码更改注册表,它在Windows 7上可以正常使用,但是在Windows 10和Windows 8上,我的成功并不相同,因为该注册表显然不再存在。 p>

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: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\"; ValueType: String; ValueName: "{app}\AppExecutable.exe"; ValueData: "RUNASADMIN"; Flags: uninsdeletekeyifempty uninsdeletevalue;
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\"; 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位应用程序,因此软件默认情况下重定向到软件SOFTWow6432Node

The Inno Setup installer is 32-bit application, so SOFTWARE gets redirected to SOFTWARE\Wow6432Node 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.

请参见 [注册表] 部分文档

See [Registry] section documentation.

使用64位安装模式

我也认为不应是 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: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"; \
    ValueType: String; ValueName: "{app}\AppExecutable.exe"; ValueData: "RUNASADMIN"; \
    Flags: uninsdeletekeyifempty uninsdeletevalue; Check: not IsWin64
Root: HKLM32; \
    Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"; \
    ValueType: String; ValueName: "{app}\AppExecutable.exe"; ValueData: "RUNASADMIN"; \
    Flags: uninsdeletekeyifempty uninsdeletevalue; Check: not IsWin64

; keys for 64-bit systems
Root: HKCU64; \
    Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"; \
    ValueType: String; ValueName: "{app}\AppExecutable.exe"; ValueData: "RUNASADMIN"; \
    Flags: uninsdeletekeyifempty uninsdeletevalue; Check: IsWin64
Root: HKLM64; \
    Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"; \
    ValueType: String; ValueName: "{app}\AppExecutable.exe"; ValueData: "RUNASADMIN"; \
    Flags: uninsdeletekeyifempty uninsdeletevalue; Check: IsWin64

这篇关于将“ RUNASADMIN”设置为Inno Setup中的应用程序兼容性标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆