Eryk Sun <eryk...@gmail.com> added the comment:

>  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".

----------
nosy: +eryksun
Added file: https://bugs.python.org/file50434/read_appexec.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45789>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to