Description
Describe the bug
I'm not sure this is the right repository, but I've seen @DrusTheAxe giving expert answers to related topics here, so I think bugs filed may reach the right people.
There are some aspects of making CreateProcess work correctly in an MSIX packaged app that aren't intuitive and there's a bug in Windows 10 that isn't documented. I had to work it out by trial and error.
On all versions of Windows if your main EXE attempts to execute an EXE that's included in your package as a helper, then it will mysteriously get ERROR_ACCESS_DENIED from CreateProcess ("Access is denied"). Nothing is logged when this happens 😢
The reason is that all EXEs, not just those started from the start menu or a %PATH% execution alias, must be listed in the AppX Manifest using <Application>
elements even if the only thing that starts them is your own code. This isn't mentioned in the docs for <Application>
nor the docs for CreateProcess
(in fact the API docs for CreateProcess
don't contain the word manifest anywhere).
On Win11 it is sufficient to create an entry for your helper EXEs in AppxManifest.xml
. Unfortunately we must still work on Win10 where it requires more effort:
- The EXE must have an embedded assembly manifest that contains the
<msix>
tag. - And it must have an
<Application>
element in the AppxManifest - And (this part is even less documented) it must also have an app execution alias!
In other words every EXE helper tool shipped in an MSIX packaged app must be added to the %PATH% if your runtime uses CreateProcess
to invoke it, even if you don't actually invoke using that execution alias.
Steps to reproduce the bug
- Create an MSIX package with a main EXE (e.g. an Electron app) and a helper EXE.
- Use
exec
from thechild_process
module to invoke the EXE. - Get "Access is denied" on stderr.
Expected behavior
Everything should just work, obviously. Process creation is the sort of thing you don't expect to break just because of choice of packaging format.
Screenshots
No response
NuGet package version
None
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 22H2 (22621, 2022 Update), Windows 10 version 22H2 (19045, 2022 Update)
IDE
No response
Additional context
No response