Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Open UWP apps from the command line on Windows 10

Aug
1,917
68
I was looking for a way to open, from the command line, Windows 10 UWP apps.

I am referring to Windows 10 UWP apps that are downloaded from the store.

While the source code for most of the Microsoft Windows 10 UWP apps can be downloaded and compiled on my system, creating an .EXE to run the UWP apps, I want to run the app as installed from the Windows Store.

I've created a test .btm, which allows the selection of a few UWP apps, and then executes the UWP app from the command line.

Reference the Microsoft Document Launch an app with a URI for details.

Joe
Code:
@setlocal
@echo off
::
:: Open UWP apps from the command line on Windows 10
::
:: URI - Uniform Resource Identifier
:: UWP - Universal Windows Platform
::
text > clip:
Alarm_Clocks
Calculator
Edge
Mail_To
Maps
Store
Terminal
To_Do's
Twitter
Weather
Get-AppxPackage
endtext

set results=%@select[clip:,1,1,20,80,Select a file from the list]

switch %results
case Alarm_Clocks
  start ms-clock:
  ::explorer.exe shell:AppsFolder\Microsoft.WindowsAlarms_8wekyb3d8bbwe!App
case Calculator
  start ms-calculator:
  ::explorer.exe shell:AppsFolder\Microsoft.WindowsCalculator_8wekyb3d8bbwe!App
case Edge
  start microsoft-edge:
case Mail_To
  start mailto:
case Maps
  explorer.exe shell:AppsFolder\Microsoft.WindowsMaps_8wekyb3d8bbwe!App
case Store
  start ms-windows-store:
case Terminal
  explorer.exe shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App
case To_Do's
  explorer.exe shell:AppsFolder\Microsoft.Todos_8wekyb3d8bbwe!App
case Twitter
  start twitter:
case Weather
  start bingweather:
case Get-AppxPackage
  ::
  :: Gets a list of the Microsoft app packages that are installed in a user profile.
  ::
  pshell /s "(Get-AppxPackage -Name Microsoft.*).PackageFamilyName" | *view
  ::
  :: Ref. https://docs.microsoft.com/en-us/powershell/module/appx/get-appxpackage?view=win10-ps
  ::
default
  echo No selection made.
endswitch
endlocal
 
Alternatively, you can create a shortcut and run the shortcut. I have a .LNK file to start MS Terminal for example. And I can start it by running the LNK file.
 
Indeed @samintz, that is an easier method.

I note that the shortcut does not provide alot of info;
Code:
c:\users\joe caverly\desktop>shortcut "Windows Terminal - Shortcut.lnk"
Command=
Arguments=
Directory=
Description=
Link=Windows Terminal - Shortcut.lnk
Icon=
Offset=0
Mode=1
Hotkey=

...yet in the Shortcut Properties dialog, it shows the target, but it cannot be copied;

1594306550447.png


Non-UWP Apps provide more info;
Code:
c:\users\joe caverly\desktop>shortcut "TCC 25.lnk"
Command=C:\Program Files\JPSoft\TCMD25\tcc.exe
Arguments=
Directory=C:\Program Files\JPSoft\TCMD25
Description=
Link=TCC 25.lnk
Icon=
Offset=0
Mode=1
Hotkey=Ctrl-Alt-T

Joe
 
Interesting! How did you make the shortcut. I have

Code:
v:\> which /a wt
wt is an external : C:\Users\vefatica\AppData\Local\Microsoft\WindowsApps\wt.EXE

I copied that file in explorer and pasted a shortcut ... giving

1594311365905.png


I can copy the target of the shortcut. When TCC executes C:\Users\vefatica\AppData\Local\Microsoft\WindowsApps\wt.EXE it waits (it shouldn't). When TCC executes the shortcut it doesn't wait. I have yet to see what C:\Users\vefatica\AppData\Local\Microsoft\WindowsApps\wt.EXE actually points to.
 
You can also

Code:
start shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App

Joe, where/how did you get the string "AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App"?
 
Hey @vefatica ,
Code:
e:\utils>which /a wt
wt is an unknown command

Was your Windows Terminal installed from the Windows Store, or did you download the source code, and compile on your system to make WT.EXE?

Joe
 
Hey @vefatica ,
In the .BTM from Post #1, take a look at Get-AppxPackage.

Also refer to the link in Post #1, "Launch an app with a URI"

Joe
 
Hey @vefatica ,
Code:
e:\utils>which /a wt
wt is an unknown command

Was your Windows Terminal installed from the Windows Store, or did you download the source code, and compile on your system to make WT.EXE?

Joe
I installed "Microsoft.WindowsTerminal_1.0.1811.0_8wekyb3d8bbwe.msixbundle" which I think came from GitHub. I think that's equivalent to downloading it from the store. I don't have the source. C:\Users\vefatica\AppData\Local\Microsoft\WindowsApps\wt.EXE is not a real EXE. It's some kind of (undocumented?) reparse point which, I imagine, points to "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.0.1811.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe".

From the looks of Scott's shortcut, he has the same set-up. I'd still like to know how he made the shortcut.

I think I read that building your own will avoid all the store bull@#$%. Did you build it?
 
I installed Windows Terminal from the store.

I downloaded the source from GitHub, but never built it, as I wanted to use the Store release.

When you install a UWP app from the store, you cannot launch it via the .EXE from the command line.

When you download from GitHub, you can launch a UWP app via the .EXE

I don't know why this is, but that's what I discovered with another UWP app.

The Desktop Shortcut for Windows Terminal was created when I installed Windows Terminal from the Store.

Joe
 
Hmmm!

I can launch WT.EXE but it's not a real app.

Code:
v:\> which /a windowsterminal
windowsterminal is an unknown command

v:\> which /a wt
wt is an external : C:\Users\vefatica\AppData\Local\Microsoft\WindowsApps\wt.EXE

c:\users\vefatica\appdata\local\microsoft\windowsapps> dir /k /m  wt*
2020-07-08  17:41               0  wt.exe

When I try to launch the real thing (even elevated) ...

Code:
v:\> "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.0.1811.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe"
TCC: (Sys) Access is denied.
 "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.0.1811.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe"
 
You need to remove the _1.0.1811.0_x64_ from the filename, which leaves
Code:
\Microsoft.WindowsTerminal_8wekyb3d8bbwe

Now, you can work that into;
Code:
explorer.exe shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App
which can launch the app.

Remember, it's an APP, not an EXE

Joe
 
Note that entering
Code:
shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App
into;
1594317955250.png

...will also work.

Joe
 
I've done some more work on my perl script to parse out the information from those UWP apps represented by zero length *.exe files in %localappdata%\microsoft\windowsapps. There are two separate entities there, the "Entry point" and the "Target". The target is the real executable, and can be run normally. The entry point would be what ends with "*!App" and can be used with the shell command.

Going back to the BTM script in the first post in this thread, that line:

pshell /s "(Get-AppxPackage -Name Microsoft.*).PackageFamilyName" | *view

does absolutely nothing on my computer.
 

Attachments

  • reparse.zip
    979 bytes · Views: 191
pshell /s "(Get-AppxPackage -Name Microsoft.*).PackageFamilyName" | *view

does absolutely nothing on my computer.
Works here, but not the "view" part (I imagine because some PowerShell DLL is doing the output). Do you have PowerShell scripting enabled. A note in the help says

PSHELL
Note that you may need to enable PowerShell scripting on your system; on recent versions of Windows it is disabled by default (for security).
 
This gets it to go to VIEW.

Code:
pshell /s "(Get-AppxPackage -Name Microsoft.*).PackageFamilyName | d:\tc28\v"
 
Working for me now, thanks. I must have been doing something wrong yesterday, I couldn't get the basic powershell command to work, never mind the "view" or "v".
 
I found some interesting powershell code. The attached script can be run from tcc with the command:

pshell resolve2.ps1

It shows the target for every zero length *.exe file in %LOCALAPPDATA%\Microsoft\WindowsApps directory.
 

Attachments

  • resolve.7z
    1.1 KB · Views: 177
UWP apps are very different from desktop apps in many ways. One significant difference between the two is that the UWP application does not have an EXE. If you want to open a UWP application, you can go through the Start menu, the list of applications in the Start menu, and create a shortcut for them on the desktop or add them to the startup folder. If you want to open UWP apps from the command line in Windows, you can. For example, it's much easier to open my games via UWP since I don't use shortcuts on the desktop. Lately, I've constantly been sitting in Minecraft on new servers Redirecting.
 
Last edited:
It isn’t quite that simple or straightforward. As best as I can determine, there is ALWAYS an executable file, somewhere, somehow. In some cases, the executable (.exe) is restricted so that you can’t run it directly. But… (you knew there was going to be a “but”, right?)

If you dig deep enough, if the real exe is restricted, then SOMEWHERE there will exist a zero length exe which is a super-special link pointing to the full size exe, and will bypass the access restriction.

For instance, Windows Terminal Preview (installed through the Store) exists here:


dir "%PROGRAMFILES%\WindowsApps\Microsoft.WindowsTerminalPreview_1.14.1452.0_x64__8wekyb3d8bbwe\wt.exe"

Volume in drive C is unlabeled Serial number is 8465:f9be
Directory of C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.14.1452.0_x64__8wekyb3d8bbwe\wt.exe

5/26/2022 18:02 96,256 wt.exe
96,256 bytes in 1 file and 0 dirs 98,304 bytes allocated
337,694,597,120 bytes free

But you cannot directly run that exe file. If you try, you will get access denied.

Howsomeever, there is a magic link located here:

%LOCALAPPDATA"\microsoft\windowsapps\microsoft.windowsterminalpreview_8wekyb3d8bbwe\wt.exe

That magic link (zero byte exe) points back to the full size exe file. You can check that with "fsutil reparsepoint query wt.exe". And when you use the magic link, you won't get an "access denied" message.

The one thing I haven't figured out (yet) is how to pass command line parameters using the magic link.

UPDATE: Dec 11,2023
I'm not sure what I was doing wrong before, but you can easily pass command line parameters using the magic link. This works, opening TCC.exe in a new WindowsTerminalPreview window.

C:\Users\Henry\AppData\Local\Microsoft\WindowsApps\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\wt.exe c:\TCMD\tcc.exe

I have a shortcut on my desktop which does exactly this.
 
Last edited:
Back
Top