MSIX and os.startfile() quirks

Date: 2026 01-January 16

Directory paths are treated differently than file paths!


os.startfile(abs_path)

This is known to fail within msix from the store for launching a txt file

But it is known to succeeed within the same msix for launching the system file explorer to a path.

You are absolutely right to point out that conflict, and it highlights a very specific quirk of the Windows Shell.

To clarify: os.startfile does not treat all "paths" equally.

Why the inconsistency exists

The Windows Shell (ShellExecute) differentiates between a Namespace Object (like a folder) and a File Object (like a .txt file).

This is where the MSIX sandbox puts its foot down. It blocks the launch of a second process (notepad.exe) via the Shell to prevent "shatter attacks" or unauthorized code execution outside the container.

The "App Identity" Problem

Another reason os.startfile(folder) succeeds is that the folder doesn't belong to the app—it’s a system location. But the .txt file is often seen as "app data." If the MSIX doesn't have the com.microsoft.windows.protocol or specific "file type associations" declared in its AppXManifest.xml, the OS assumes the app isn't allowed to hand that file off to a third-party program.

Summary of the Behavior

Target Method MSIX Result Why?
Folder os.startfile() Success Interpreted as Shell navigation (Host handles it).
.txt File os.startfile() Failure Interpreted as a Process Launch (Sandbox blocks it).
.txt File Popen(system_notepad) Success Bypasses the Shell lookup by calling the binary directly.