22

How can I run an app installed from Windows Store (https://github.com/microsoft/terminal) from the command line, please?

1

6 Answers 6

21
start shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App

By default an alias is enabled for Windows Terminal, so you can also use:

"%userprofile%\AppData\Local\Microsoft\WindowsApps\wt.exe"

Example app not from Microsoft:

start shell:AppsFolder\XINGAG.XING_xpfg3f7e9an52!App

Where the string XINGAG.XING_xpfg3f7e9an52
can be found as folder in %userprofile%\AppData\Local\Packages

Other ways of doing this are explained here

2
  • 3
    Note that the suffix won't always be !App, and the name of the folder won't necessarily be easy to match with the actual app ((for example, for Gears Tactics it's Microsoft.GanderBaseGame_8wekyb3d8bbwe!GanderShippingInternal). The link at the bottom of the answer has a more foolproof way to get the proper command line. I took a shortcut and used SysExporter to get the execution command from the properties dialog (nirsoft.net/utils/sysexp.html). Commented Nov 24, 2020 at 0:32
  • How to pass a file to open with this app using this method ?
    – Chamod
    Commented Jun 26, 2021 at 18:08
6

Here's a "pure command-line" method using PowerShell to determine the method(s) for launching a Store/UWP app. To me, this is much simpler than the method discussed in the article linked in the currently accepted answer. It also has the advantage of being more deterministic, IMHO.

As discussed in the main answer, there are two possible methods for launching Store/UWP apps:

  • App execution alias. Note that apps that are added to the user's WindowsApps folder are on the path by default and do not need a fully qualified name. For example, just wt will work for Windows Terminal. You can view the list via the Manage app execution aliases setting.

    But there can also be app execution aliases that are not on the path. For instance, most games, like Minecraft will have an app execution alias that can be launched if you know its fully-qualified path.

  • For those apps that don't have an app-execution alias, you can fallback to the shell:AppsFolder method, using either start or explorer.exe to launch.

The main challenge in both of these methods is determining the actual command to use for each app. That's where the methods below come in. The starting point for finding the launch command is always going to be the AppxPackage itself. But sometimes finding the package can be more difficult than others:

  • The "easy" case -- Just filter Get-AppxPackage's return results for one matching the Name. Using Windows Terminal as an example:

    Get-AppxPackage |? { $_.Name -like "*Terminal*" } | tee-object -Variable packageMatches
    
  • However, some apps are oddly named. For instance, the Minecraft Dungeons package name is Microsoft.Lovika, which I assume was its project name during development. Unless you know what you are looking for, you may want to perform a (slower) search based on the manifest DisplayName:

    Get-AppxPackage |? {
        (Get-AppxPackageManifest -Package $_.PackageFullName).Package.Properties.DisplayName -like "*Mine*" 
    } | tee -variable packageMatches
    

Once you have the $packageMatches result, you can find the ways that it can be launched:

  • Using the fully-qualified path to the app execution alias, if one is available. To determine this:

    $packageMatches |% {
        $executableName = ((Get-AppxPackageManifest -Package $_.PackageFullName).Package.Applications.Application.Executable)
        if ($executableName) {
            "Start-Process ""$($_.InstallLocation)\$executableName"""
        } else {
            "No executable found"
        }
    }
    

    Note: The Start-Process format that this returns is simply for launching from PowerShell with simplified quoting rules for paths-with-spaces. Adapt as needed for other launchers.

  • If there is no app execution alias for the app, you can fall back to using the explorer.exe shell:appsFolder\<PackageFamilyName>!<Id> method, of course. To obtain the correct name and id:

    $packageMatches |% {
        "explorer.exe shell:appsFolder\$($_.PackageFamilyName)!$((Get-AppxPackageManifest -Package $_.PackageFullName).Package.Applications.Application.Id)"
    }
    

    For example, any PWA (progressive web app) or website installed through Edge as an application will be not have an executable, but will be launchable through explorer.exe.

2

Starting a normal app from the command line (or a script, or a scheduled task) is easy. Just start the executable. But apps that are installed from the Windows Store don't have executables. So how do you start them?

The simplest way is if the app has a custom protocol. If it does then it's just a case of calling start and then the protocol. So, you could do something like this:

start microsoftvideo:

If you want to add a custom protocol to your app see

https://msdn.microsoft.com/windows/uwp/launch-resume/handle-uri-activation

If the app doesn't have its own custom protocol then you'll have to launch it via the shell. Actually, the shell has its own protocol so you call something like this:

start shell:AppsFolder\Microsoft.WindowsStore_8wekyb3d8bbwe!App
2

An easy way is to create a shortcut and then from the command line to execute the ".lnk" file generated.

1
  • 1
    It can also provide the correct string to use for those who want to use the method in the other answers. For example for kodi I saw on the shortcut created it's XBMCFoundation.Kodi_4n2hpmxwrvr6p!Kodi (I had no other way of knowing about the !Kodi at the end)
    – Nom1fan
    Commented Aug 20, 2021 at 14:17
1

Some apps create binaries in %LOCALAPPDATA%\Microsoft\WindowsApps.

If not found there you can launch the app via its shortcut and look for the actual path in the task manager.

0

I got a little frustrated with how difficult this was so I wrote my own script/app to launch apps from the app store in command line. It is super simple with a .\launch.ps1 -list and .\launch.ps1 <app name> interface.

It is available here:

https://github.com/jonmchan/windows-app-cmdline-launcher

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .