microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
23.11k stars 1.44k forks source link

Run as admin to avoid UAC spam? #2999

Open IngwiePhoenix opened 1 year ago

IngwiePhoenix commented 1 year ago

Description of the new feature / enhancement

I reinstalled my PC's Windows 10 as part of my annual PC and digital cleaning. This time around, I exported my winget packages and stored it alongside my Windows 10 installer, allowing me to, immediately after getting into the desktop, re-install all my 96 packages.

My first attempt was to run winget import pkgs.json, but was surprised to read that winget does not like running from within an admin shell. So I had to sift through an astounding amount of UAC prompts, which certainly sucked.

This is why I would like to request a feature to winget to allow importing - or even upgrading - from an elevated shell to avoid UAC spam.

Thanks!

Proposed technical implementation details

No response

denelon commented 1 year ago

@IngwiePhoenix WinGet does work when running in both "user" and "administrator" context. The challenge is really associated with the installers themselves. We've added "requiresElevation" and "prohbitsElevation" as keys that can be added to manifests to help with packages that do not work in those scopes, but we also have challenges when dealing with packages that want to be installed either for a single user or for a machine wide install.

We will take a look at this in the future to see if there is something we can do better here.

IngwiePhoenix commented 1 year ago

Gotcha. Attempting to consolidate what was effectively a "wild west of installation methods" into a package manager truely sounds challenging. Thank you for all the work!

feoh commented 7 months ago

Just wanted to say you can do this now with sudo for Windows - available to Windows Insiders.

I'm running it now:

sudo winget upgrade --all

Running like a champ with zero UAC faff! PRICELESS! :)