3

I'm struggling to launch the WSL "Ubuntu 20.04" Store App (or any Store App, really) from the command-line (e.g. PowerShell or CMD).

When I run Ubuntu 20.04 from the Start Menu, it launches in a window with the Ubuntu icon and the correct window title ("Ubuntu 20.04 LTS"). I'd like to get that same application window when launched from the command-line.

I've searched quite a bit, and found this page that references start shell:AppsFolder\{folder}!App (e.g. start shell:AppsFolder\Microsoft.WindowsStore_8wekyb3d8bbwe!App), but I haven't been able to make that work for the Ubuntu Store App. It seems a bit convoluted to me -- Is there an easier way? And if not, how does that work for Ubuntu?

I'm familiar with the wsl command, but if I run wsl -d Ubuntu-20.04 from the Start Menu, the resulting window has the generic WSL/Linux/Penguin icon instead of the Ubuntu icon. The window title is also C:\Windows\system32\wsl.exe instead of "Ubuntu 20.04 LTS."

If I run the same wsl command from CMD, it still has the CMD icon.

Perhaps I could use the DOS/CMD TITLE command, but I'd like to just have a command I can use to launch the Store app. Is this possible?

By contrast, "normal" .exe Windows apps can be launched from CMD or PowerShell quite easily.

I'd be really happy with a solution for Ubuntu WSL, but also if there is simple (and notably, programmable) way to run all Windows Store Apps, that would be great.

11
  • I am not sure I understand. Start, WSL, wait for it to start, kex --esm --ip is , password and the WSL machine starts. Seems straightforward to me.
    – anon
    Commented Sep 28, 2021 at 19:28
  • Note: a) from the console, and b) programmable. "kex --esm --ip is kex : The term 'kex' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."
    – YorSubs
    Commented Sep 28, 2021 at 19:28
  • You could go through all this or without even researching the answer, I am guessing that you could use the System Internals Process Explorer to see what command line the thingy you want was launched with. On the other hand, you could use the method you and I are bickering about in another post and use a windows shortcut. Commented Sep 28, 2021 at 20:06
  • 1
    @YorSubs Hopefully you will accept some constructive criticism. Your use of hyperbole in your questions ("ludicrous") and answers ("relic") may turn some folks off and discourage careful reading of the rest of the question. Also, to be honest, your original question lacks some clarity, details, and readability. If you don't mind, I'll try to do some edits on it to improve it (since I seem to have understood what you are asking). You are free to roll these back or make additional edits if you wish. Commented Sep 28, 2021 at 21:17
  • 1
    That's fine, I accept that. I know I was a little salty this evening, and indeed, my question here could be more tightly worded (I really do think that UWP issues like this are an unnecessarily complex constructs, it's very confusing to me that they created them in such a hard to manipulate way.
    – YorSubs
    Commented Sep 28, 2021 at 21:26

3 Answers 3

2

Providing this as a separate answer since, as you've noticed, App Execution Aliases (from my other answer) aren't created by all WSL distributions.

The page that you came across on how to use start shell:/AppsFolder... is on the right track, but misses a key point -- The !App at the end works for most but not all UWP/Store apps. I actually came across this last year when I was trying to back up my Minecraft Dungeons progress, oddly enough ...

The actual syntax is:

start shell:AppsFolder\PackageFamilyName!AppId

PackageFamilyName typically matches the directory name in C:\Program Files\WindowsApps, but that directory is not typically readable unless you have elevated your permissions via UAC.

And AppId is the real challenge to find. It's defined in the XML manifest for the package. And it can be whatever the developer wants it to be. Most do use App, but there are (especially for WSL, it seems) exceptions.

Here's a PowerShell snippet to run through all of your user's Appx packages (Store-installed as well as those that come with Windows) along with a few "system" packages:

Get-AppxPackage | ForEach-Object {
  $packageFamilyName = $_.PackageFamilyName
  $packageManifest = Get-AppxPackageManifest $_
  $displayName = $packageManifest.Package.Properties.DisplayName
  $appId = $packageManifest.Package.Applications.Application.Id

  Write-Output "${displayName}: ${packageFamilyName}!${appId}"
}
  • Get-AppxPackage: Enumerate the installed packages
  • $_.PackageFamilyName: Should match the directory name in C:\Program Files\WindowsApps for most non-system packages
  • Get-AppxPackageManifest returns the XML package manifest for the app
  • Then we get the DisplayName and AppId properties by traversing the XMLDocument as PowerShell/.Net properties.

You should be able to use the resulting output with the start (CMD) or Start-Process (PowerShell) a la:

start-process shell:AppsFolder\36828agowa338.AlpineWSL_my43bytk1c4nr!alpinewsl

But do, of course, check your actual output from the above Get-AppxPackage test above, since the Family name can change based on the Store release, I believe.

For me, this launched a separate Windows Console with Alpine, with the Alpine logo and title.

2
  • This is perfect. Indeed, it was after finding that !App failed for Ubuntu and trying to find the AppId's that I posted my question. Your snippet here to derive the correct string is ideal, unlocking all Windows Store Apps to start from the console (this was what I was hoping for from the searches that I made, but they all proposed clunky manual solutions while this works for every UWP app).
    – YorSubs
    Commented Sep 30, 2021 at 5:53
  • 1
    One minor thing: $appId is actually an array. I knew this previously from reading some of the web pages I searched, but one Windows Store App can have multiple associated applications, and you can see this explicitly for the base system ms-resource://microsoft.windowscommunicationsapps which contains "Mail", "Calendar", and "ManageAccounts", so for complete automation, we would also have to split up the $packageManifest.Package.Applications.Application.Id array, but your answer gives me everything I need to manipulate these objects. 👍
    – YorSubs
    Commented Sep 30, 2021 at 7:30
7

Short answer:

From CMD or PowerShell:

start ubuntu.exe

If start isn't aliased under PowerShell, try:

start-process ubuntu.exe

More detail:

ubuntu.exe is the "App Execution Alias" for the "Ubuntu" app installed from the Microsoft Store, although it's possible that it could also be:

  • ubuntu2004.exe: If you installed the "versioned" "Ubuntu 20.04" from the Store
  • ubuntu1804.exe: If you installed the "versioned" "Ubuntu 18.04"
  • And I'll assume that you don't still have the deprecated 16.04 version around.

You can see this by going to Manage app execution aliases in Windows Settings. Many Store apps include a "fake .exe" that is designed to launch the Store app. You can disable this, but I'm assuming it's enabled. If not, enable it, of course.

When you run Ubuntu from the Start Menu, it is, of course, running the Store app. This app runs WSL in the legacy Windows Console, and does a couple of additional things such as set the application icon and font. That's pretty much the only difference than I can find from running it from the command-line.

When you run ubuntu.exe (or one of the other WSL app execution aliases) from the command-line, it is started in the current terminal. It's the same as typing ipconfig.exe, for instance. It retains the current characteristics of the "owning" terminal (started by CMD or PowerShell) -- Same app icon, same fonts, etc.

When run with the start (CMD) or Start-Process (PowerShell) command, it starts a separate process in Windows (rather than as a subprocess of the current shell). Windows launches it in a new terminal (Windows Console by default), and presumably, WSL does some magic to say "if I'm the owner of the terminal, then set the icon and font".

8
  • Sadly, I get errors when I do this on both Cmd or PowerShell. On Cmd, it says "Windows cannot find ubuntu.exe" and from PowerShell, start is not allowed, and ubuntu.exe is not found if I run it alone. Where is that ubuntu.exe binary located on your system?
    – YorSubs
    Commented Sep 28, 2021 at 20:41
  • 1
    @YorSubs It could be different (which was in my edited answer that I'm working on). Search for "App Execution Alias" in the Start menu. See what the execution alias is for your Ubuntu Store App. Commented Sep 28, 2021 at 20:44
  • It says ubuntu2004.exe in there, so I'm trying that ... well, that's amazing, it works perfectly. This is very interesting indeed, as I don't know if you saw the link in my original question, but the methods on the internet to invoke a Windows Store App are incredibly convoluted and gnarly. From PowerShell, I see that I can also do cmd.exe /c start ubuntu2004.exe. I wonder if there is a way on the command line to list out the currently defined "App Execution Alias". I guess this must be in the registry somewhere.
    – YorSubs
    Commented Sep 28, 2021 at 20:49
  • 1
    @YorSubs Right, ubuntu2004.exe is an alternative in my (still in process) answer, but most installations are just ubuntu.exe. Look for the full post in a few minutes, then I'll look at the App Execution Alias question :-) Commented Sep 28, 2021 at 20:53
  • Reading the comments on this page, I see that there are still significant issues with invoking UWP apps, and I see that, unfortunately, there are no "App Execution Aliases" for my other distros (CentoOS and Alpine) so I still have no way to invoke those, but for Ubuntu, it seems that the App Execution Alias is always created at least. windowscentral.com/how-manage-app-execution-aliases-windows-10
    – YorSubs
    Commented Sep 28, 2021 at 20:54
1

If you have installed ubuntu 2024 then just type ubuntu2024 and hit enter in the command window. It logs into ubuntu in the same command window.

You must log in to answer this question.

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