Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launching a Windows 10 UWP app from the command line cmd

I would like to be able to launch a Windows 10 UWP app from a single command line (cmd Windows 10) input. I am having issues concatenating the strings together to form the entire package name (this needs to be dynamic because the ending string of the app can change with each deployment). Here is the logic I have:

  1. Find the app package name in the LocalAppData directory (i.e. packageName_postfix)
  2. Append "!App" to the end of the result in #1
  3. Pass that string into the launch function:

I have gotten to a point where I can find #1, but for some reason when I try to append it to #2, I get a NULL value. Here is my current command:

1.) & 2.): Get Package Name and Append it to "!App"

set "x=|dir %LocalAppData%\Packages /b | findstr packageName" & set "y=!App" & set "z=%x%%y%" & echo.%z%

3.): Launch UWP App

explorer.exe shell:appsFolder\packageName_postfix!App

Any ideas?

like image 574
user1682015 Avatar asked Aug 18 '18 18:08

user1682015


1 Answers

First you must know this solution only work on Windows 10 Fall Creators Update and newer versions. This API will support Windows Insider Build version 16266 or greater.

Add this namespace in Pacakge.appxmanifest file :

xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"  

Then add this extension :

<Extensions>  
    <uap5:Extension   
      Category="windows.appExecutionAlias"   
      Executable="MyApp.exe"   
      EntryPoint="MyApp.App">  
      <uap5:AppExecutionAlias>  
        <uap5:ExecutionAlias Alias="MyApp.exe" />  
      </uap5:AppExecutionAlias>  
    </uap5:Extension>  
  </Extensions>  
  • Executable name - Application.Exe name (Ex: MyApp.exe)
  • EntryPoint - Entrypoint tag should contain the Full name of the application class(Ref: open -> App.xaml file -> Application x: Class name)
  • AppExecutionAlias - Type alias name in command prompt to open the application; give the app.exe name as alias name.

Build the application and run it one time!

Open command Prompt, type the alias name -> Enter

You can also see the reference Here

like image 168
Parsa Karami Avatar answered Oct 29 '22 02:10

Parsa Karami