winget fails as SYSTEM with 0xC0000135
winget works when you run it yourself. Run as SYSTEM on a fresh Windows 11 box, it exits with 0xC0000135 before it does anything, so every deployment that runs it as SYSTEM fails.
UPDATED
On a fresh Windows 11 install, winget can work for the person logged on and crash at load for the SYSTEM account. Run as SYSTEM, winget --version exits with -1073741515, which is 0xC0000135, STATUS_DLL_NOT_FOUND. winget.exe is on the disk and starts, then Windows cannot find a DLL it needs and the process ends.
Every deployment that runs winget as SYSTEM fails on such a box, for the same reason each time. The user at the keyboard sees nothing wrong.
The missing DLLs are the Visual C++ x64 runtime, vcruntime140.dll and msvcp140.dll. App Installer’s Microsoft.VCLibs.140.00.UWPDesktop framework package forwards to them, and a fresh or minimal Windows image does not have that runtime installed. A developer’s machine usually does, from Visual Studio or another tool, which is why the fault shows up on new boxes and rarely on the one you test from. We have not proven why only SYSTEM is affected. Our reading is that winget started from a user’s session runs as a packaged app, with its framework packages in reach. Started by path as SYSTEM, it goes through the ordinary DLL search, which needs the runtime installed on the machine.
Confirming it by hand
The winget most people type is an alias in the user’s own profile, %LocalAppData%\Microsoft\WindowsApps\winget.exe, and SYSTEM has no such alias. So under SYSTEM, “‘winget’ is not recognized” only tells you the alias is missing. Call the executable by its full path instead.
Open PowerShell as SYSTEM, for example with Sysinternals PsExec (psexec -s -i powershell.exe), and run:
$winget = Resolve-Path 'C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe' | Select-Object -Last 1 -ExpandProperty Path
& $winget --version
'0x{0:X8}' -f $LASTEXITCODE
A working winget prints its version, then 0x00000000. A box with this fault prints 0xC0000135. Run winget --version in your own session on the same box, and it works.
Why Repair-WinGetPackageManager says all is well
The usual advice for a broken winget is Repair-WinGetPackageManager -AllUsers. On a box with this fault it reported “WinGet is in a good state”, because it checked winget as the interactive user, where nothing is wrong. It also needs PowerShell 7. Under the Windows PowerShell 5.1 that ships with Windows 11, it stops with “This cmdlet is not supported in Windows PowerShell.” Our own first repair called it from Windows PowerShell, and it never worked on a stock endpoint.
The fix by hand
Install Microsoft’s Visual C++ x64 runtime, vc_redist.x64.exe (from https://aka.ms/vs/17/release/vc_redist.x64.exe), machine-wide on each affected box:
vc_redist.x64.exe /install /quiet /norestart
Then run the check above again as SYSTEM. On the box we followed most closely, winget loaded as SYSTEM right after the install, with no reboot.
On a fleet, the hard part is finding the boxes, because nobody logged on to them sees a problem. After that, the fix typically means packaging the redistributable in your deployment tool, targeting the affected machines, and waiting for it to run.
What Attestree does
The agent runs as SYSTEM, so on such a box every winget step it runs hits this fault. It checks winget as SYSTEM on a schedule and reports a box with this fault to the console as “SYSTEM winget cannot load (VC++ runtime missing)”. Rollout operations describes the fleet-wide winget health signal this feeds. While winget is broken on a box, the agent holds every winget step there and does not count it as an install failure. On a box with several App Installer versions, agent 26.11.700 and later run and check the newest winget.
The repair is off until an admin switches it on for the tenant. It is one setting, and once it is on it covers every ring. From then on the agent notices the fault by itself, installs the Visual C++ runtime it carries inside its own installer, pinned by hash, and checks winget again. Since agent 26.11.700 that check runs straight after the repair, so the console no longer shows the old “broken” verdict for up to 30 minutes, and a box still broken after a repair that reported success reads broken. Nothing is downloaded at repair time, so the repair also works on an isolated network. The setting travels in the signed desired state, so a tampered response cannot switch it on.
The repair has worked on every fresh machine we have enrolled, in our lab and on our test instance, with no help from an operator.
Twice, a fresh box in our lab was never offered the repair: once because the repair was armed only for the first ring by default, and once because of a server bug that served the box an empty desired state. Both were found and fixed.