winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Winget doesnt run as system on fresh windows installs, even after running windows update and store updates

Open JamesFCroft opened this issue 1 year ago • 11 comments

Brief description of your issue

Winget not running as system on a fresh install of Windows

This means it cannot be used with Intune to roll out software

Steps to reproduce

Install a fresh copy of Windows (I did mine as a VM) Windows 11 pro and Windows 11 enterprise tested, 23H2 and 22H2 SW_DVD9_Win_Pro_11_22H2.24_64BIT_English_Pro_Ent_EDU_N_MLF_X23-81095 Download PSexec From an admin command prompt, Run PSexec -s CMD run whoami to confirm you are NT\system. cd c:\program files\windowsapps dir to get the path, something like Microsoft.DesktopAppInstaller_8wekyb3d8bbwe CD to that directory Run winget.exe No output will be displayed nor logs appear in the diagoutput directory, it should go to c:\windows\temp if run as system. No install commands work, or viewing version of winget

image

Drop out to a normal command prompt as admin user and it works fine.

Expected behavior

Packages should install - blogs from 2023 as discussed on this site, report it is working, with the only issue of the exe not being in a PATH system variable Logs should appear for every run

Actual behavior

Fails to run without any errors reported

Environment

Windows Package Manager v1.8.1911
Windows: Windows.Desktop v10.0.22631.4037
Package: Microsoft.DesktopAppInstaller v1.23.1911.0

JamesFCroft avatar Sep 07 '24 23:09 JamesFCroft

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] avatar Sep 07 '24 23:09 github-actions[bot]

+1 same problem here

c-vo avatar Sep 09 '24 01:09 c-vo

Winget has never worked properly, especially on clean installations, even though it comes pre-installed. The installation is often broken, preventing it from running or updating. The best solution is to install it directly.

Start-BitsTransfer -Source "https://github.com/microsoft/winget-cli/releases/download/v1.8.1911/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Destination "$env:USERPROFILE\Downloads\Microsoft.DesktopAppInstaller.msixbundle"
Add-AppxPackage -Path "$env:USERPROFILE\Downloads\Microsoft.DesktopAppInstaller.msixbundle"

surgatengit avatar Sep 09 '24 01:09 surgatengit

Workaround: In my case, the only solution that worked was separately installing the latest Microsoft Visual C++ Redistributable, followed by a reboot.

c-vo avatar Sep 09 '24 12:09 c-vo

Workaround: In my case, the only solution that worked was separately installing the latest Microsoft Visual C++ Redistributable, followed by a reboot.

Yes! installing VC_redist.x64 fixed this for me Thank you for taking the time to reply!

JamesFCroft avatar Sep 09 '24 21:09 JamesFCroft

Does the Visual C++ Redistributable really need a reboot?

maumeerally avatar Oct 11 '24 09:10 maumeerally

We've also built the Repair-WinGetPackageManager cmdlet in the Microsoft.WinGet.Client PowerShell module to help with bootstrapping issues.

denelon avatar Oct 21 '24 22:10 denelon

I'll use it once its supported on PowerShell 5.1

maumeerally avatar Oct 25 '24 15:10 maumeerally

The latest version of Microsoft.WinGet.Client should be working correctly in Windows PowerShell.

You will need to specify "-Scope System" so you get "machine wide" install since the system context doesn't have a "logged in" user. Note, some package installers don't support the system context, and some explicitly prohibit machine wide installs.

Have you encountered any issues with the latest version of the module in Windows PowerShell?

denelon avatar Oct 25 '24 18:10 denelon

I just don't think it's ready for use with Autopilot just yet as that is my primary purpose of it. Especially after https://github.com/microsoft/winget-pkgs/issues/180404 meant both Microsoft Office and Google Chrome were unable to install for a day or two. Can't turn around to the end user and say hey your machine failed to build because the winget pipeline had issues.

Been leveraging deployment methods in the following projects which seem to indicate as per the comments above installing the latest Visual C++ Redistributable is required to get the SYSTEM context to work: https://github.com/djust270/Intune-Scripts/blob/master/Winget-InstallPackage.ps1 https://github.com/Romanitho/Winget-Install

maumeerally avatar Oct 28 '24 09:10 maumeerally

The latest version of Microsoft.WinGet.Client should be working correctly in Windows PowerShell.

You will need to specify "-Scope System" so you get "machine wide" install since the system context doesn't have a "logged in" user. Note, some package installers don't support the system context, and some explicitly prohibit machine wide installs.

Have you encountered any issues with the latest version of the module in Windows PowerShell?

I used the -MTA Parameter and the -Scope System to install apps in Intune running as SYSTEM, it finally works (For me) 👍

HarmVeenstra avatar May 01 '25 22:05 HarmVeenstra

Does the Visual C++ Redistributable really need a reboot?

I just ran into this issue for the first time despite clean installing loads of devices this year, I fixed by installing the redist but no reboot was needed. I need to try the scope option to see if it works without the redist, my script already set the scope to machine though, and has been working well for a couple of years.

Update: I edited my winget install script to add a check for vcredist and if not installed, download and install it. Onboarded a fresh system using the same Windows image and to the same tenant and it worked perfectly. Not sure why this is the first time I have experienced this though.

incedIT avatar Sep 05 '25 14:09 incedIT