Published in Articles on by Michiel van Oosterhout ~ 3 min read

When scouring the Windows 11 Settings app you may come across App execution aliases under Advanced app settings. These are a mechanism in Windows whereby a the execution of a program is redirected to a different program.

Windows 11 app execution aliases in the Settings app
Windows 11 app execution aliases in the Settings app

You may have noticed aliases for python.exe and python3.exe in this list. Apparently Microsoft wants to help people that don't have Python installed and attempt to run the python command, by redirecting them to the Microsoft Store where they can install Python.

Python in the Microsoft Store
Python in the Microsoft Store

Normally app execution aliases are keys in the Windows Registry under HKCU:\Software\Microsoft\Windows\CurrentVersion\App Paths. But you will not find keys for the Python aliases in the Windows Registry.

The python.exe and python3.exe aliases are actually tiny (0 bytes) files located in %LOCALAPPDATA%\Microsoft\WindowsApps. This directory is added to your PATH environment variable by default, so these executables are resolved.

The `PATH` environment variable in Windows 11
The PATH environment variable in Windows 11

But the files are not real applications, their size is 0 bytes! So how can this work? The secret is that the files are NTFS reparse points. These are files that store data in a separate stream, which does not count towards the file size. You can get the data using fsutil reparsePoint query %LOCALAPPDATA%\Microsoft\WindowsApps\python.exe, and you will see the text Microsoft.DesktopAppInstaller in the data.

When we look at the package manifest of the Microsoft.DesktopAppInstaller package, then we find the source of the Python app execution aliases. One of the applications in the package, PythonRedirector, has two ExecutionAlias extensions:

<Application Id="PythonRedirector" Executable="AppInstallerPythonRedirector.exe">
    <Extensions>
        <uap5:Extension Category="windows.appExecutionAlias">
            <uap5:AppExecutionAlias>
                <uap8:ExecutionAlias Alias="python.exe" uap8:AllowOverride="true" />
                <uap8:ExecutionAlias Alias="python3.exe" uap8:AllowOverride="true" />
            </uap5:AppExecutionAlias>
        </uap5:Extension>
    </Extensions>
</Application>

If we want to remove the app execution aliases, we may try to uninstall Microsoft.DesktopAppInstaller, but this is not possible:

This app is part of Windows and cannot be uninstalled on a per-user basis.

We can try to remove the python.exe and python3.exe files, but if we try that via Windows Explorer we get an error (probably because these are reparse points):

An unexpected error is keeping you from deleting the file. If you continue to receive this error, you can use the error code to search for help with this problem.

Error 0x80070780: The file cannot be accessed by the system.

The files can however, be removed using fsutil reparsePoint delete %LOCALAPPDATA%\Microsoft\WindowsApps\python.exe. This will not be reflected in the Settings app however, because it uses C:\Windows\System32\Windows.StateRepositoryPS.dll to keep track of the state of these app execution aliases, and if you bypass the Settings app then it does not update the state.

Summary

Normally app execution aliases can be easily removed by removing keys from the Windows Registry, but the aliases for Python originate in the Microsoft.DesktopAppInstaller package. Although we can delete the NTFS reparse points, the Settings app will not reflect the correct state.