Set “RUNASADMIN” application compatibility flag in Inno Setup

后端 未结 1 1537
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-14 20:40

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 wo

相关标签:
1条回答
  • 2021-01-14 21:17

    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.

    The Inno Setup installer is 32-bit application, so SOFTWARE gets redirected to SOFTWARE\Wow6432Node by default.

    You have to use an explicit 64-bit registry root like Root: HKLM64 to explicitly avoid the redirection.

    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.

    Or use 64-bit install mode.


    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
    
    0 讨论(0)
提交回复
热议问题