More configurable settings and arguments for install scope
Description of the new feature / enhancement
If a user specifically runs sudo winget install... in terminal, it's pretty likely that they intend to install an application with --scope machine. I might be wrong about this, but I think it would be convenient if running such a command defaulted to machine scope instead of user.
Proposed technical implementation details
No response
WinGet defaults to "user" scoped install (assuming that's available in the manifest). Running "sudo" does grant elevation, but it does not change the behavior of WinGet. I would see this as a breaking change.
Some installers like Git will perform their own checks to determine if the user is a member of local administrators so even passing "--scope" user doesn't always work as expected.
There are cases where a "user" based install does need elevation. One example is installing a service. Unfortunately, things aren't quite as consistent as we would like them to be.
I could see the potential for a setting to change the default behavior. We currently have "preferences" and "requirements" in settings around the default scope, but not one for a conditional scope for when elevation is being used.
Ah, makes sense. Well a configurable setting would be just as convenient! Fingers crossed 🤞🏽
I changed the title to more align with what I'm thinking the feature would be.
I don't think we need to change anything if the user passes in "--scope". If we can detect the call to WinGet is elevated, we could have another setting in the settings file to specify something like "machine wide" install as default when elevated.
The default would most likely stay as "user", but folks could override that with their settings.
If a user specifically runs
sudo
But can you detect this as opposed to the user having an elevated terminal for other reasons? Do you suggest winget should check the name of the parent process?
Just checking if the user has a split token would not give enough context.