我有一个使用 Desktop to UWP Bridge 转换的应用程序,特别是 Desktop App Converter这一切都是自动完成的。它可以很好地转换和安装,但是当我尝试运行它时,我收到一个错误,指出可执行文件需要提升。我可以通过 Right Click -> Run as Administrator
来解决这个问题,但我希望将应用程序重新打包为默认设置,这样就不需要这个额外的步骤了。值得注意的是,我可以在没有管理员权限的情况下以正常安装方式运行该应用程序,只有转换后的应用程序才需要这样做。
有没有办法在与转换应用相关联的 AppxManifest.xml
文件中包含所需的提升请求?我希望有像
<Application Id="MyApp" Permissions="Administrator">
list 上有文档 here但我找不到任何与权限或提升级别相关的信息。
这是转换器生成的AppxManifest.xml
。
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10">
<Identity Name="MyApp" ProcessorArchitecture="x86" Publisher="CN=Me" Version="5.70.0.0" />
<Properties>
<DisplayName>MyApp</DisplayName>
<PublisherDisplayName>Me</PublisherDisplayName>
<Logo>Assets\AppStoreLogo.png</Logo>
</Properties>
<Resources>
<Resource Language="en-us" />
<Resource uap:Scale="100" />
<Resource uap:Scale="125" />
<Resource uap:Scale="150" />
<Resource uap:Scale="200" />
<Resource uap:Scale="400" />
</Resources>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
<Applications>
<Application Id="MyApp" Executable="Integrator.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="MyApp" Description="MyApp" BackgroundColor="transparent" Square150x150Logo="Assets\AppMedTile.png" Square44x44Logo="Assets\AppList.png">
<uap:DefaultTile Wide310x150Logo="Assets\AppWideTile.png" Square310x310Logo="Assets\AppLargeTile.png" Square71x71Logo="Assets\AppSmallTile.png">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo" />
<uap:ShowOn Tile="wide310x150Logo" />
<uap:ShowOn Tile="square310x310Logo" />
</uap:ShowNameOnTiles>
</uap:DefaultTile>
</uap:VisualElements>
<Extensions>
<uap3:Extension Category="windows.fileTypeAssociation">
<uap3:FileTypeAssociation Name="gfe">
<uap:SupportedFileTypes>
<uap:FileType>.gfe</uap:FileType>
</uap:SupportedFileTypes>
</uap3:FileTypeAssociation>
</uap3:Extension>
<uap3:Extension Category="windows.fileTypeAssociation">
<uap3:FileTypeAssociation Name="gfs">
<uap:SupportedFileTypes>
<uap:FileType>.gfs</uap:FileType>
</uap:SupportedFileTypes>
</uap3:FileTypeAssociation>
</uap3:Extension>
<uap3:Extension Category="windows.appExecutionAlias" Executable="Integrator.exe" EntryPoint="Windows.FullTrustApplication">
<uap3:AppExecutionAlias>
<desktop:ExecutionAlias Alias="Integrator5.exe" />
</uap3:AppExecutionAlias>
</uap3:Extension>
</Extensions>
</Application>
</Applications>
</Package>
最佳答案
更新:从 Windows 10 更新 1809(内部版本 17763)开始,您现在可以声明“allowElevation”功能以启用自动/自行提升。这是有关此功能的教程:https://stefanwick.com/2018/10/01/app-elevation-samples-part-1/
上一个答案(适用于 1809 之前版本的 Windows 10):
目前不支持应用程序的自动提升。不过,用户可以选择以管理员身份运行您的应用。
Desktop Bridge 的准备指南中提到了此策略: https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-prepare (项目符号 #2)
谢谢, Stefan Wick - Windows 开发者平台
关于c# - 始终以管理员身份运行使用 Windows 桌面桥转换的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43267968/