Why does the .exe file of a Modern App fail to run and produces an error regarding the app container?

8,576

Solution 1

You can run a Windows modern app from the command line using an explorer.exe shell command like this:

explorer.exe shell:AppsFolder\<Package Name>_<Publisher ID>!<App ID>

Or, via start, which is recommended if you need to pass arguments:

start shell:AppsFolder\<Package Name>_<Publisher ID>!<App ID> arg1 arg2

The trick is discovering the Package Name, Publisher ID, and App ID. It would be nice if all this info were available on the Microsoft Store listing for the app, or in Task Manager, or on the app's listing in Settings -> Apps & features. So far, I have found no easy way to collect those three pieces of information. Here are steps to do so using Task Manager and File Explorer, copied from my blog post.

  1. Open the modern app as you normally would, from the Start menu, task bar, etc.
  2. Launch Task Manager (I right-click on the Windows task bar and choose "Task Manager")
  3. Expand the listing for the app you're interested in, right-click on the child item, and choose "Go to Details"
  4. Right-click on the highlighted executable and choose "Open file location"
  5. The name of the directory you just opened gives you the Package Name and the Publisher ID, if you know how to parse them out. Using the Calendar app as an example, the directory name, "microsoft.windowscommunicationsapps_16005.12827.20560.0_x64__8wekyb3d8bbwe", starts with the Package Name ("microsoft.windowscommunicationsapps"), is followed by version and platform information that you don't need for this ("16005.12827.20560.0_x64"), and then comes the Publisher ID ("8wekyb3d8bbwe"). Note the Package Name and Publisher ID for later use.
  6. Open the AppxManifest.xml file in that directory
  7. Near the top of the AppxManifest.xml file, you'll find an Identity element, with a Name attribute -- confirm that this value matches the package name, which we already got from the directory name
  8. Search the AppxManifest.xml file for the executable name, e.g., HxCalenderAppImm.exe, and you'll find an XML element that looks like this:
This gives you the third piece of information you need: the Application ID.

Now that you've collected the three pieces of information we need, you can build the command to open the app from the command line.

  1. Your command will look like this, replacing the portions with the three pieces of information collected above:

    explorer.exe shell:AppsFolder\<Package Name>_<Publisher ID>!<App ID>

Continuing with the example of the Calendar app from the Mail and Calendar package, you would enter something like this:

explorer.exe shell:AppsFolder\microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.windowslive.calendar

Dear Microsoft: Please make this easier!

Solution 2

Prior to Windows 8, you could have "standalone" .exe applications. Installation was mainly to create links and references to make it easy for the application to find what it needed and run. If everything the application needed was provided by the application, itself, it could run without installation. The app-container is a security concept introduced with Win 8. Without installation, an application has access to its own folders and little else, including most devices. An application must be designed to work with app-containers in order to be installed. This link has a decent description of the concept and how it works.

Edit: For an installed application, it appears that all of the associations and permissions are attached to the tile, so the .exe cannot be run directly.

Share:
8,576

Related videos on Youtube

Teo Zec
Author by

Teo Zec

I am 15 years old and I am studying in Berchet grammar school in Milan, but my passion is programming. I am learning C language, and I also know a (very very) little bit of C#, C++, Visual Basic and HTML.

Updated on September 18, 2022

Comments

  • Teo Zec
    Teo Zec almost 2 years

    Inside the C:\Program Files\WindowsApplications folder there are the .exe files for the Modern Apps on my PC. When I double-click on one of them, a pop-up tells me:

    This application can run only in the context of an app container
    

    Is there a way to run a Modern app directly from its .exe file, and not only by its tile?

    Thank you in advance!

    P.S.: I'm on Windows 10 technical preview.

    • rrirower
      rrirower over 9 years
      Should probably be asked on stack overflow.
    • Teo Zec
      Teo Zec over 9 years
      @rrirower I don't know... It isn't directly related to programming
    • Ramhound
      Ramhound over 9 years
      If your asking how to run your own Modern UI programs you are going to have to provide us more details.
    • Teo Zec
      Teo Zec over 9 years
      @Ramhound It's not developed by me. Check the edit for details
    • Teo Zec
      Teo Zec over 9 years
      @Ramhound I'm really sorry: I've discovered that the app is actually installed on my PC. So the question is: why can't I run it from its .exe file?
    • Ramhound
      Ramhound over 9 years
      Why can't you run it from the .exe because that's how Windows Store applications are design. If you cannot run the application at all that's something else entirely.
    • Teo Zec
      Teo Zec over 9 years
      @Hennes Actually, I've tried it only on Windows 10 Technical Preview, but I think it works the same for all the three OS's
  • Ramhound
    Ramhound over 9 years
    You really should quote the relevant part of the website. The blog could disappear tomorrow and what would be left wouldn't be that helpful.
  • Teo Zec
    Teo Zec over 9 years
    Hi, thanks for your answer. I don't need to run an app of mine and to create an app-container from it directly in my source code. I wasn't clear in the question, check the edit for more detail
  • fixer1234
    fixer1234 over 9 years
    @Ramhound - I looked at trying to do that. If you check out the link, it is long and solid, relevant information. I tried to paste the whole thing with attribution but there was too much internal formatting and it would have been a major job to reformat everything.
  • Teo Zec
    Teo Zec over 9 years
    I've understood what is written in the link. However, my question is if it is possible you run a Modern App (inside its application container) directly from its .exe file, and not from its tile
  • fixer1234
    fixer1234 over 9 years
    I'm going to guess from your experience that the answer is no. I'm guessing that all of the associations and permissions are attached to the tile.
  • Ramhound
    Ramhound over 9 years
    If your not willing to put in the time to make a question excellent then I cannot take the time to upvote it. I am still concerned that if that blog were to go down then this answer wouldn't be helpful.
  • fixer1234
    fixer1234 over 9 years
    @Ramhound - The link is supplementary information in case someone is interested in the inner workings of the app container. It isn't critical to answering the question, so the relevance of the answer wouldn't be affected if the link was to disappear. However, it is somewhat irrelevant at this point. After posting my answer, the OP clarified that the question was actually something different. I would have simply deleted the answer, but someone found it useful so I left it. In general, though, I agree with you and do attempt to summarize links.
  • DavidPostill
    DavidPostill over 7 years
    Please read the question again carefully. Your answer does not answer the original question.
  • xaml
    xaml over 7 years
    Hello to you too. That may have been the case, had I not clarified that even though an answer was promised, the presented findings of tinkering with the "Windows Scan" application were supposed to be regarded as a comment and not an answer or an answer to some degree only.
  • DavidPostill
    DavidPostill over 7 years
    It's still not an answer. At best it is a comment.
  • xaml
    xaml over 7 years
    There was no claim about the contribution being an answer, as the second part of the first sentence clearly stresses. While dedication usually should be regarded as commendable, I would think that there must be more valuable things to do than to evoke bickering of a meticulous kind.
  • Shrukul Habib
    Shrukul Habib almost 4 years
    Finally an answer that explains how to pass command line arguments to uwp apps during launch. Thanks for the sample commands!