This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, firewave, paul.moore, steve.dower, tim.golden, zach.ware
Date 2021-11-12.06:04:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1636697050.15.0.0684457248025.issue45789@roundup.psfhosted.org>
In-reply-to
Content
>  It fails with "The system cannot find the file 
>  C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\python3.9.exe."

The shell's CreateProcessW() call failed with ERROR_FILE_NOT_FOUND (2). The file exists, but it's probably a broken appexec link. I'm attaching a script that displays the contents of an appexec link. For example, here's the working "python3.9.exe" link:

    C:\>read_appexec.py "%LocalAppData%\Microsoft\WindowsApps\python3.9.exe"
    Version: 3
    Package ID: PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0
    Entry Point: PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0!Python
    App Type: 0
    Target Path:
    C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\python3.9.exe

---

> The executable in Program Files cannot be launched except in a few
> oddly specific circumstances.

The SYSTEM, LOCAL SERVICE, and NETWORK SERVICE accounts can directly execute the real executable. For standard users, however, a conditional access control entry is set in the file's permissions that allows execute access only if the accessing security context has the app's WIN://SYSAPPID, such as "PYTHONSOFTWAREFOUNDATION.PYTHON.3.9_QBZ5N2KFRA8P0". When CreateProcessW() spawns an app from an appexec link, it adds the required WIN://SYSAPPID to a new token that gets created for the process. The app itself can thus directly load and execute binary images (EXEs, DLLs) from its installation directory under "%ProgramFiles%\WindowsApps".
History
Date User Action Args
2021-11-12 06:04:10eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, firewave
2021-11-12 06:04:10eryksunsetmessageid: <1636697050.15.0.0684457248025.issue45789@roundup.psfhosted.org>
2021-11-12 06:04:10eryksunlinkissue45789 messages
2021-11-12 06:04:09eryksuncreate