如何在Windows 10中从PowerShell启动通用Windows应用(UWP)?

Ton*_*ony 4 powershell uwp

在PowerShell中,如果运行Get-AppxPackage则会获得安装的UWP应用程序列表,包括我的。例如:

Name              : TonyHenrique.tonyuwpteste
Publisher         : CN=tTony
Architecture      : X64
ResourceId        :
Version           : 1.1.12.0
PackageFullName   : TonyHenrique.tonyuwpteste_1.1.12.0_x64__h3h3tmhvy8gfc
InstallLocation   : C:\Program Files\WindowsApps\TonyHenrique.tonyuwpteste_1.1.12.0_x64__h3h3tmhvy8gfc
IsFramework       : False
PackageFamilyName : TonyHenrique.tonyuwpteste_h3h3tmhvy8gfc
PublisherId       : h3h3tmhvy8gfc
IsResourcePackage : False
IsBundle          : False
IsDevelopmentMode : False
Dependencies      : {Microsoft.NET.CoreRuntime.2.1_2.1.25801.2_x64__8wekyb3d8bbwe, Microsoft.VCLibs.140.00.Debug_14.0.25805.1_x64__8wekyb3d8bbwe,
                    TonyHenrique.tonyuwpteste_1.1.12.0_neutral_split.scale-100_h3h3tmhvy8gfc}
IsPartiallyStaged : False
SignatureKind     : Developer
Status            : Ok
Run Code Online (Sandbox Code Playgroud)

现在,我想启动这个程序。

如何在PowerShellcmd中执行此操作?

Ben*_*red 9

如果您知道显示名称,则可以使用Get-StartApps,其中包含正确的后缀:

start "shell:AppsFolder\$(Get-StartApps "Groove Music" | select -ExpandProperty AppId)"
Run Code Online (Sandbox Code Playgroud)


Jet*_*per 6

在 PowerShell 中尝试一下:

start shell:AppsFolder\TonyHenrique.tonyuwpteste_h3h3tmhvy8gfc!App
Run Code Online (Sandbox Code Playgroud)


apk*_*apk 6

在开发过程中,我遇到了这样的情况:应用程序的姓氏有时会更改。您可以通过简单的查找按名称可靠地启动应用程序:

  • 如果它是您的应用程序,或者在特定情况下可以使用,但是由于未指定`!App`,因此无法普遍使用。例如Microsoft.BingNews_8wekyb3d8bbwe!AppexNews (2认同)
  • 看起来可以在AppxManifest.xml中为关联的应用程序标记找到!Appx或!AppxNews后缀:<Application Id =“ AppexNews” Executable =“ Microsoft.Msn.News.exe” EntryPoint =“ Microsoft.Msn.News。应用“> (2认同)

Ste*_*SFT 5

借助 Windows 10 Fall Creators Update 1709(内部版本 16299),您现在可以为 UWP 应用定义应用执行别名,以便您可以从 cmd 或 powershell 轻松启动它:

<Extensions>
    <uap5:Extension
      Category="windows.appExecutionAlias"
      StartPage="index.html">
      <uap5:AppExecutionAlias>
        <uap5:ExecutionAlias Alias="MyApp.exe" />
      </uap5:AppExecutionAlias>
    </uap5:Extension>
</Extensions>
Run Code Online (Sandbox Code Playgroud)

此外,我们现在支持 UWP 应用的命令行参数。您可以从 OnActivated 事件中读取它们:

async protected override void OnActivated(IActivatedEventArgs args)
{
    switch (args.Kind)
    {
        case ActivationKind.CommandLineLaunch:
            CommandLineActivatedEventArgs cmdLineArgs = 
                args as CommandLineActivatedEventArgs;
            CommandLineActivationOperation operation = cmdLineArgs.Operation;
            string cmdLineString = operation.Arguments;
            string activationPath = operation.CurrentDirectoryPath;
Run Code Online (Sandbox Code Playgroud)

见博文:https : //blogs.windows.com/buildingapps/2017/07/05/command-line-activation-universal-windows-apps/