Skip to content

Win11 26H2: user PATH (~3.6k) not applied to new processes — winget missing in cmd/PS 5.1/pwsh #6606

Open

Description

After a recent Windows 11 26H2 upgrade, new shells stop loading the user PATH from the registry, so winget and other user-scoped tools vanish from cmd, PowerShell 5.1, and PowerShell 7 even though App Installer and winget.exe are still installed.

Environment

  • OS: Windows 11 26H2 (build 10.0.26300)
  • App Installer / winget: Microsoft.DesktopAppInstaller 1.29.380 (package status OK)
  • winget.exe at %LOCALAPPDATA%\Microsoft\WindowsApps\winget.exe runs when invoked by full path (winget --version → v1.29.380)
  • User PATH in registry (HKCU Environment\Path): ~3,632 characters, includes %LOCALAPPDATA%\Microsoft\WindowsApps and 13 ...\Microsoft\WinGet\Packages\... entries (typical winget portable install pattern without Developer Mode / admin Links layout)

Steps to reproduce

  1. Accumulate a large user PATH (common with multiple winget portable/zip packages that each append a long WinGet\Packages\... segment).
  2. Upgrade to Windows 11 26H2 (or open a new cmd / PowerShell 5.1 / pwsh session after upgrade).
  3. Run where winget in cmd or Get-Command winget in PowerShell 5.1 or pwsh.
  4. Compare [Environment]::GetEnvironmentVariable('Path','User') (registry) vs $env:Path in the same process.

Expected

  • User PATH from HKCU is merged into every new interactive shell (cmd, PowerShell 5.1, pwsh).
  • winget resolves via the App Execution Alias under WindowsApps when App Installer is installed.
  • If a platform limit applies, Windows should surface a clear error or warning when user PATH cannot be applied — not silently drop the entire user block.

Actual

  • Registry user PATH length ~3632; process PATH length ~1326 (matches machine PATH only — user PATH not applied at all).
  • where winget in cmd: not found.
  • Get-Command winget in PowerShell 5.1 and pwsh: not found.
  • Direct invocation still works: & "$env:LOCALAPPDATA\Microsoft\WindowsApps\winget.exe" --version.
  • PowerShell profile import of Microsoft.WinGet.CommandNotFound fails at startup because ValidateOS.psm1 requires Get-Command winget to succeed.

Related

  • winget-cli #3601 — PATH bloat from portable installs
  • winget-cli #5557 — repeated WinGet package PATH entries vs 2047 limit
  • winget troubleshooting: missing %LOCALAPPDATA%\Microsoft\WindowsApps in PATH (docs)

Ask

  1. OS: Fix or document behavior when user PATH exceeds legacy limits — do not silently omit the entire user PATH from new processes.
  2. winget: Default to Links/symlink layout where possible; warn when appending another Packages\... segment would exceed safe PATH size; offer cleanup for duplicate or stale entries.
  3. Visibility: A high-signal diagnostic (e.g. winget doctor or Settings) when App Execution Aliases exist but PATH was not applied.

Workaround (local)

  • Shorten HKCU PATH (dedupe, remove per-package WinGet paths, keep WinGet\Links + WindowsApps) and sign out / reboot.
  • turso config set autoupdate off-style: winget only via full path until PATH is repaired.

Activity

  1. AMDphreak commented on Oct 20, 2026

    @AMDphreak
    ContributorAuthor

    Fix the PATH size limitation.

  2. R-Adrian commented on Oct 21, 2026

    @R-Adrian

    when you refer to those new shells, are you running them elevated and the Administrator Protection GPO is enabled?
    If so then it probably uses the HKCU of the elevated profile and not the HKCU of the regular profile.

  3. added
    Issue-Bug
    and removed
    Needs-Triage
    on Oct 24, 2026
  4. SunnyLeu commented on Nov 7, 2026

    @SunnyLeu

    I investigated a very similar issue and reproduced the complete loss of the User PATH on three Windows 11 installations. My findings strongly suggest that this behavior originates from Windows Shell32's environment-regeneration logic rather than WinGet itself.

    1. Controlled reproduction on Windows 11 24H2

    I performed controlled tests on a relatively clean Windows 11 24H2 virtual machine:

    • OS build: 26100.4770
    • shell32.dll version: 10.0.26100.4768
    • Machine PATH length: 128 characters
    • Test environment: Standard, non-elevated, 64-bit Windows PowerShell 5.1
    • Third-party shell modifications: ExplorerPatcher was not installed

    The following results were observed:

    Expected combined PATH length PATH after Shell32 regeneration Result
    4094 4094 Correct
    4095 128 (Machine PATH only) Entire User PATH omitted
    4094 (repeated) 4094 Correct

    Screenshot — original 4095-character failure:

    Original Windows 11 24H2 Shell32 PATH failure at 4095 characters

    Additional tests established that:

    • The problem occurs with both REG_SZ and REG_EXPAND_SZ User PATH registry values.
    • Combined PATH lengths of 4095, 4096, 4097, 5000, 8192, and 10000 characters all resulted in a Machine-only PATH after Shell32 regeneration on the VM.
    • CreateEnvironmentBlock successfully constructed the complete PATH from the same registry values, including lengths exceeding 4095 characters.
    • The internal, undocumented shell32.dll!RegenerateUserEnvironment function returned TRUE even when the entire User PATH was omitted.
    • Repeating the 4094-character test after the failure restored the expected behavior, confirming a reproducible length boundary.

    Test evidence

    The VM testing covered 24 controlled runs across multiple target lengths and both registry value types.

    These files contain results from the actual VM experiments, not simulated output.

    2. Independent reproduction on Windows 11 26H2

    I also tested two Windows 11 26H2 installations:

    • OS build: 26300.9818
    • shell32.dll version: 10.0.26100.9949

    The results were consistent with the VM findings:

    1. Remote PC: The exact 4094/4095 boundary was independently reproduced, with a Machine PATH length of 1144 characters. The combined PATH was correct at 4094 characters, but at 4095 characters the regenerated PATH contained only the Machine portion.

    2. Primary PC: The existing combined Process PATH was 4162 characters. Calling RegenerateUserEnvironment produced a Machine-only PATH of 2204 characters. The exact 4094/4095 boundary was not separately tested on this PC.

    These observations indicate that the problem is not limited to the particular 24H2 VM or to systems with ExplorerPatcher installed.

    3. Root-cause investigation

    Using WinDbg on the clean Windows 11 24H2 VM, I traced the failing behavior to a length check inside:

    shell32!BuildEnvironmentPath

    At the 4095-character boundary, the relevant conditional branch is taken, causing the function to skip the operation that appends the User PATH.

    Controlled debugging, including an in-memory branch modification within a disposable VM process, provided strong causal evidence that this length check is responsible for the observed behavior.

    Detailed debugger evidence has been submitted privately to Microsoft for further assessment.

    For clarity, the instruction-level investigation was performed on shell32.dll version 10.0.26100.4768 (Windows 11 24H2). The two 26H2 installations reproduced the observable failure, but their internal machine code was not independently disassembled.

    4. Relevance to this WinGet issue

    The symptoms described in this issue are highly consistent with the behavior I reproduced:

    • The User PATH remains present in HKCU\Environment\Path.
    • Newly constructed or regenerated process environments may contain only the Machine PATH.
    • Executables installed in User PATH directories are no longer found through normal command lookup.
    • The executables themselves remain installed and can still be invoked by their absolute paths.

    However, I cannot independently confirm that the original reporter's system has the exact same underlying cause without equivalent diagnostics.

    Regarding elevation and Administrator Protection

    A previous comment asked whether the problem might be related to elevated shells or Administrator Protection.

    My clean-VM reproduction used a standard, non-elevated PowerShell process. Therefore, elevation or Administrator Protection is not required to reproduce this particular Shell32 environment-regeneration failure.

    Why this matters beyond WinGet

    This behavior can affect any application, developer tool, or automation script that relies on executable directories in the User PATH.

    Although WinGet portable package installations may contribute to PATH growth, the demonstrated failure occurs within Windows Shell32's environment-regeneration logic.

    5. Suggested follow-up

    I recommend:

    1. Windows engineering: Investigate the length handling and silent failure behavior in Shell32's environment-regeneration path.
    2. WinGet maintainers: Consider reducing unnecessary PATH growth from portable package installations, removing duplicate entries where appropriate, or warning users about unusually large PATH values.
    3. Diagnostics: Consider exposing a clear warning when registered user executable paths are not reflected in the effective process PATH.

    The most concerning aspect is that the User PATH can disappear from the regenerated environment without an error being reported by RegenerateUserEnvironment.

    I hope the controlled reproduction results and attached evidence help identify the underlying Windows component and route the issue to the appropriate engineering team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions