Windows 10 UWP apps launch and then disappear immediately

uwpwindows 10

The Problem

When trying to run certain Provisioned Windows apps on Windows 1903, the apps seem to open and then just disappear very quickly—and this is the problem.

Troubleshooting

Upon inspecting the Event Viewer Application logs, there are Event ID 1000 events logged. Furthermore, upon inspection of the Event Viewer | Application and Services Logs | Microsoft | Windows | Apps and within the Microsoft-Windows-TWinUI/Operational log, there are Event ID 5961 events logged.

Event Viewer Error Codes

  • Event ID: 1000: Exception code: 0xc000027b
  • Event ID: 5961: Error code: Unknown HResult Error code: 0x80040904. Activation phase: COM App activation

Some of What I've Tried

I've tried running the below PowerShell and reinstall the applications that have this problem, and it appears to run without error, but the problem still occurs.

$wAppPath = (Get-AppxPackage -Name "*Calc*").InstallLocation;
Add-AppxPackage -Path "$wAppPath\Appxmanifest.xml" -Register -DisableDevelopmentMode;

Further Detail

This problem seems to only occur with accounts configured as auto logons which have their profiles deleted at shutdown and startup both (yes both) using the DelProf2 method.

Event Viewer Details

Event ID 1000

Faulting application name: Calculator.exe, version: 10.1812.1901.4008, time stamp: 0x5c304989
Faulting module name: Windows.UI.Xaml.dll, version: 10.0.18362.356, time stamp: 0x0825b5b0
Exception code: 0xc000027b
Fault offset: 0x0000000000712cf0
Faulting process id: 0x1518
Faulting application start time: 0x01d568dbe3b0f42c
Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1812.10048.0_x64__8wekyb3d8bbwe\Calculator.exe
Faulting module path: C:\Windows\System32\Windows.UI.Xaml.dll
Report Id: 23d86f95-8eec-407b-b52c-86043d6d0426
Faulting package full name: Microsoft.WindowsCalculator_10.1812.10048.0_x64__8wekyb3d8bbwe
Faulting package-relative application ID: App
  • enter image description here

Event ID 5961

Activation for Microsoft.WindowsCalculator_8wekyb3d8bbwe!App failed. Error code: Unknown HResult Error code: 0x80040904. Activation phase: COM App activation
  • enter image description here

Best Answer

One way to resolve this problem is to register the applicable UWP Provisioned Windows apps, and each of those applications' dependencies. Below is some PowerShell logic that is run while logged on as a user account experiencing the problem, with a login script, etc. and fixes the issue.

Note: This may only need to be run once to resolve this problem for others, my situation may be more on the unique side than the norm.

I confirmed that this PowerShell solution fixes this with at least two UWP apps (e.g. Calc and Photos). I figured out the PowerShell after looking over some of the logic in the Program.cs on GitHub here after confirming a run of the RegAllAppX.exe located there also resolves the problem.

The execution of that executable file on GitHub takes way too long to run, in my case at least as it needs run at every logon of the account with the problem as it gets a new profile each time it logs onto Windows 10 automatically. I think DelProf2 is not wiping the profile properly and causing the problem but a more native solution is on the back burner for now but may come in the future.

Looking over some of the logic in the Program.cs code you can research, test, and translate to equivalent PowerShell logic to perform similar operations in a more targeted and efficient manner for the specific UWP apps that experience the problem.

PowerShell

$Apps = @("WindowsCalculator","Photos");

$base   = @();
$depend = @();
$Apps | %{
    $base   += $base   = (Get-AppxPackage -Name "*$_*").InstallLocation;
    $depend += $depend = (Get-AppxPackage -Name "*$_*").Dependencies.InstallLocation;
    };

$Apps = (($base + $depend) | Sort -Unique);
$Apps | %{Add-AppxPackage -Path "$_\Appxmanifest.xml" -Register -DisableDevelopmentMode};

Supporting Resources

  • Arrays
  • ForEach-Object

    Standard Aliases for Foreach-Object: the '%' symbol, ForEach

  • Get-AppxPackage

  • Add-AppxPackage

    • You can use the Register parameter to install from a folder of unpackaged files during development of Windows® Store apps

    • You can use DisableDevelopmentMode to register an application that is staged by the StagePackageAsync API, has been disabled, or has become corrupted during testing.

  • About Assignment Operators

    +=: Increases the value of a variable by the specified value, or appends the specified value to the existing value.

  • Sort-Object

    Standard Aliases for Set-Alias: sort

  • PackageManager Class
Related Question