10

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?

1

5 Answers 5

10

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
    
2
  • 2
    This works if it's your app, or for a specific case, but can't be used universally as !App is not given. e.g. Microsoft.BingNews_8wekyb3d8bbwe!AppexNews
    – papo
    Commented Jun 8, 2018 at 8:33
  • 2
    It looks like the !Appx or !AppxNews suffix can be found in AppxManifest.xml for the associated Application tag: <Application Id="AppexNews" Executable="Microsoft.Msn.News.exe" EntryPoint="Microsoft.Msn.News.App">
    – Rob Meyer
    Commented Oct 15, 2018 at 17:10
9

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)"
8

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/

2
  • I've similar issue posted here that has no solution so far. I was wondering if you have any solution/idea? Thank you.
    – nam
    Commented Jul 25, 2019 at 19:56
  • Is it possible to close UWP app from PowerShell, because I've tried and it doesn't; also starting process with "-passthrough" parameter doesn't return anything
    –  Tims
    Commented Feb 26, 2023 at 5:19
6

Try this in PowerShell:

start shell:AppsFolder\TonyHenrique.tonyuwpteste_h3h3tmhvy8gfc!App
1
  • Based on your answer, I ended using: explorer.exe shell:AppsFolder\TonyHenrique.tonyuwpteste_h3h3tmhvy8gfc!App
    – Tony
    Commented Oct 23, 2017 at 20:51
0

I know it's an old post, but I built a function to do it.
Hope it helps other folks.

function Start-UniversalWindowsApp {

    [CmdletBinding()]
    param (
        [Parameter(
            Mandatory,
            Position = 0,
            ValueFromPipeline,
            ValueFromPipelineByPropertyName = $false
        )]
        [ValidateNotNullOrEmpty()]
        [string]$Name,
        
        [Parameter()]
        [pscredential]$Credential
    )

    $queriedapp = $Global:UwpList | Where-Object { $PSItem.Name -like "*$Name*" }
    if (!$queriedapp) { Write-Error -Exception [System.Data.ObjectNotFoundException] -Message "No app was found with the name '$Name'." }
    if ($queriedapp.Count -gt 1) {
        $indexapplist = @()
        for ($i = 1; $i -le $queriedapp.Count; $i++) {
            $indexapplist += [pscustomobject]@{ Index = $i; App = $queriedapp[$i - 1] }
        }

        Write-Host @"
More than one app was found for the name $($Name):

"@

        $indexapplist | ForEach-Object { Write-Host "$($PSItem.Index) - $($PSItem.App.Name)" }
        $usrinput = Read-Host @"

Select one or all packages.
[I] Package Index  [A] All  [C] Cancel
"@

        while (($usrinput -ne 'A') -and ($usrinput -ne 'C') -and ($usrinput -notin $indexapplist.Index) ) {
            if ($usrinput) {
                Write-Host "Invalid option '$usrinput'."
            }
        }

        $appstorun = $null
        switch ($usrinput) {
            'A' { $appstorun = $queriedapp }
            'C' { $Global:LASTEXITCODE = 1223; return }
            Default { $appstorun = ($indexapplist | Where-Object { $PSItem.Index -eq $usrinput }).App }
        }

    }
    else {
        $appstorun = $queriedapp
    }

    if ($Credential) {
        foreach ($app in $appstorun) {
            Start-Process -FilePath 'explorer.exe' -ArgumentList "shell:AppsFolder\$($app.PackageFamilyName)!App" -Credential $Credential
        }
    }
    else {
        foreach ($app in $appstorun) {
            Start-Process -FilePath 'explorer.exe' -ArgumentList "shell:AppsFolder\$($app.PackageFamilyName)!App"
        }
    }

}
1
  • Do you know the way to close it afterwards?
    –  Tims
    Commented Feb 26, 2023 at 19:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.