Is there a supported way to map a Windows Sandbox ID to its host window or client process?

Vancsisin László 0 Reputation points
2026-11-27T16:50:41.3666667+00:00

I’m building a local Windows tool that needs to identify the host-side remote desktop window for a specific Windows Sandbox session. My environment is Windows 11 on ARM64 with Windows Sandbox package version 0.8.114.0.

The CLI documentation says that wsb start returns a Sandbox ID, wsb list lists Sandbox IDs for the current user, and wsb connect --id <id> opens a remote desktop window for the selected Sandbox. Given a known HWND, GetWindowThreadProcessId returns the ID of the thread that created the window and can also return the process ID. I haven’t found a documented way to go from the Sandbox ID to that HWND or to the specific host-side client process instance. Windows Sandbox CLI · GetWindowThreadProcessId

Does Windows Sandbox expose a supported API, CLI output field, or event schema that provides this mapping? If so, could you link to the documentation and clarify which identifier to use, how long it remains valid, and how to distinguish sessions when multiple Sandbox windows are open or a client reconnects?

If no supported mapping is exposed, could Microsoft confirm that?

Windows development | Windows API - Win32
0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-11-27T16:51:49.8933333+00:00

    No supported public contract currently maps a Windows Sandbox ID to a host-side HWND, host client PID, or durable client-connection identifier.

    The Windows Sandbox CLI defines the Sandbox ID only as the identifier used by Sandbox commands such as list, connect, exec, share, ip, and stop. Its documented output does not include a host window handle, process ID, connection ID, or corresponding event field.^1^

    Identifier scope

    For the documented CLI:

    • wsb start creates the Sandbox and returns its Sandbox ID.
    • wsb list reports IDs for the current user's Sandbox sessions.
    • wsb connect --id <id> opens a new remote-session window.
    • wsb stop --id <id> terminates that Sandbox and closes its desktop window.^1^

    Therefore, treat the ID as an identifier for the Sandbox environment, not for a particular client window or connection. The documentation does not define:

    • an ID-to-HWND or ID-to-host-PID query;
    • a window property containing the Sandbox ID;
    • stability of an associated client process across reconnects;
    • a connection-generation identifier;
    • an ETW or Windows Event Log correlation schema.

    The CLI itself is described as an early/preview command-line feature in the newer Store-delivered Sandbox available from Windows 11 24H2.^2^

    Why Win32 window enumeration cannot complete the mapping

    GetWindowThreadProcessId supports the reverse lookup from an already-known HWND to the thread and process that created that window.^3^ It does not expose Sandbox metadata, so enumerating windows and retrieving their PIDs cannot produce a supported correlation to a particular Sandbox ID.

    Matching by process name, title text, creation time, window order, or by observing the process launched around wsb connect would consequently be heuristic. It could break when:

    • the client reconnects or is replaced;
    • more than one client window exists;
    • window titles or implementation details change;
    • another process brokers or owns the visible window.

    Such heuristics should not be used as an identity or security boundary.

    Newer automation tooling does not provide that contract

    The WinApp CLI can bind its operations to a Sandbox ID with --expect-sandbox, but this checks that the expected Sandbox is running; it does not provide session ownership or boot-identity guarantees. The documentation specifically says to use a new GUID for each wsb start, because restarting under the same GUID is not detected.^4^

    For example:

    $id = [guid]::NewGuid().ToString()
    wsb start --id $id
    winapp run . --on sandbox --expect-sandbox $id
    

    winapp target snapshot sandbox --json can report readiness and guest windows without reconnecting the client. However, the reported UI PIDs and handles are guest-side identifiers, not host client-window identifiers. The same documentation notes that several client windows can make capture ambiguous and that the caller must resolve the candidates; it does not document a Sandbox-ID-to-host-HWND association.^4^

    Practical supported boundary

    If the tool needs to control a known Sandbox, keep and use the Sandbox ID only with documented wsb operations. Generate a fresh GUID for each launch if the tool needs to distinguish its own Sandbox generation:

    $id = [guid]::NewGuid().ToString()
    wsb start --id $id
    
    wsb connect --id $id
    wsb list --raw
    
    # Later:
    wsb stop --id $id
    

    If the requirement specifically needs the host HWND—for example, to position, embed, monitor, or capture that exact client window—there is no documented supported mapping for package version [IP Address] in the available public interface. A formal product commitment or confirmation would require a Microsoft support case or a Windows Sandbox feature request; an implementation discovered through window enumeration would remain unsupported unless Microsoft publishes a corresponding API contract.


    References

    1. Windows Sandbox command line interface
    2. Windows Sandbox versions
    3. GetWindowThreadProcessId function (winuser.h)
    4. Windows Sandbox execution
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.