Inno Setup 的安装程序在上传和下载周期后不需要管理员权限

Inno Setup's installer doesn't require admin rights after uploading and downloading cycle

我让我的 Unity 游戏从服务器下载新版本的安装程序到 AppData/LocalLow/MyProject/Temp 并尝试 运行 它。源可执行文件确实需要 UAC 以 运行 作为管理员,正如它所设想的那样。

PrivilegesRequired=admin

但是当我将安装程序上传到服务器并下载它时,出现错误消息"Unable to create temp folder. Access denied"。

FC says it is complete copy,但一个正在请求许可 - 另一个没有。

我通过转换为 byte[] 并通过 POST 发送来上传文件,下载 - GET 反之亦然

当我尝试自己 运行 这个可执行文件时也会发生这种情况。就是不想向我要权利


此外,作为解决方案,我试图强制我的游戏 运行 具有管理员权限的新进程:

如果我使用 Mono,我可以通过 运行 安装程序的过程:

new Process
{
    StartInfo =
    {
         Verb = "runas", 
         FileName = Updater.GetPathToInstaller()
    }
}.Start();

但是我需要使用 IL2CPP,而 Unity 的 IL2CPP 还没有包含 System.Diagnostics.Process,所以我使用 this solution 到 运行 我的安装程序。

而且我不知道如何使用管理员强制它 运行。


安装程序清单:

я╗┐<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity name="JR.Inno.Setup" processorArchitecture="x86" version="1.0.0.0" type="win32"></assemblyIdentity>
<description>Inno Setup</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
    </dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
        <requestedPrivileges>
            <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
        </requestedPrivileges>
    </security>
</trustInfo>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
        <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
    </windowsSettings>
</application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
        <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>
        <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"></supportedOS>
        <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>
        <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"></supportedOS>
        <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"></supportedOS>
    </application>
</compatibility>
</assembly>

"Copy" 的清单相同

所以,我发现我的问题是由于我下载后将安装程序设置为低完整性级别引起的。为什么?因为我把它下载到 Application.persistantDataPath,也就是 LocalLow 文件夹。我将下载文件夹更改为不持久的 Application.dataPath,并且在我的测试场景中是在桌面上,它工作正常 - 安装程序的下载副本没有低 MIC

当然我仍然需要注册我的安装程序,正如@MartinPrikryl 在评论中提到的那样,以避免智能屏幕出现问题,但这不是我的 "It doesn't request the permission, but still needs it" 问题的解决方案