Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Start a Universal Windows App (UWP) from PowerShell in Windows 10?

Tags:

powershell

uwp

In PowerShell, if I run Get-AppxPackage, I get a list of UWP apps installed, including mine. For example:

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

Now I want to start this app.

How to do this in PowerShell, or in cmd?

like image 416
Tony Avatar asked Oct 23 '17 15:10

Tony


People also ask

How do I launch the UWP app?

If you want to open a UWP app, you can go through the Start Menu, the apps list in the Start menu, you can create a desktop shortcut for them, or add them to the start up folder. If you want to open UWP apps from the command line on Windows, you can.

Can UWP run on Windows 10?

UWP is one choice for creating apps that run on Windows 10 and Windows 11 devices, and can be combined with other platforms. UWP apps can make use of Win32 APIs and .

How do I fix UWP app not opening?

Please run Windows Store Apps troubleshooter from Settings app > Update & security > Troubleshoot. See if it helps you. Hope this helps!


4 Answers

During development, I've encountered a situation where the app family name occasionally changed. You can reliably launch an app by name with a simple lookup:

  • Cmd

    powershell.exe explorer.exe shell:AppsFolder\$(get-appxpackage -name YourAppName ^| select -expandproperty PackageFamilyName)!App
    
  • Powershell

    explorer.exe shell:AppsFolder\$(get-appxpackage -name YourAppName | select -expandproperty PackageFamilyName)!App
    
like image 112
apk Avatar answered Oct 21 '22 04:10

apk


With the Windows 10 Fall Creators Update 1709 (build 16299) you now have the ability to define an app execution alias for your UWP app, so you can launch it easily from cmd or powershell:

<Extensions>
    <uap5:Extension
      Category="windows.appExecutionAlias"
      StartPage="index.html">
      <uap5:AppExecutionAlias>
        <uap5:ExecutionAlias Alias="MyApp.exe" />
      </uap5:AppExecutionAlias>
    </uap5:Extension>
</Extensions>

Furthermore, we now support commandline arguments for UWP apps. You can read them from the OnActivated event:

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;

See blog post: https://blogs.windows.com/buildingapps/2017/07/05/command-line-activation-universal-windows-apps/

like image 38
Stefan Wick MSFT Avatar answered Oct 21 '22 05:10

Stefan Wick MSFT


Try this in PowerShell:

start shell:AppsFolder\TonyHenrique.tonyuwpteste_h3h3tmhvy8gfc!App
like image 44
Jet Chopper Avatar answered Oct 21 '22 04:10

Jet Chopper


If you know the display name, you can use Get-StartApps, which includes the correct suffix:

start "shell:AppsFolder\$(Get-StartApps "Groove Music" | select -ExpandProperty AppId)"
like image 31
Ben Allred Avatar answered Oct 21 '22 05:10

Ben Allred