Repository navigation
Act on elevation requirements in majority cases - #2126
Conversation
check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absentactivatable amd Archs dsc enr FWW Globals hackathon lww mytool Packagedx parametermap Uninitialize WDAG whatif wsbTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the [email protected]:JohnMcPMS/winget-cli.git repository |
| <value>Prompts the user to press any key before exiting</value> | ||
| </data> | ||
| <data name="InstallerElevationExpected" xml:space="preserve"> | ||
| <value>The installer will request to run elevated, expect a prompt.</value> |
|
|
||
| // This installer cannot be run elevated, but we are running elevated. | ||
| // Implementation of de-elevation is complex; simply block for now. | ||
| if (installer->ElevationRequirement == ElevationRequirementEnum::ElevationProhibited && Runtime::IsRunningAsAdmin()) |
There was a problem hiding this comment.
if (installer->ElevationRequirement == ElevationRequirementEnum::ElevationProhibited && Runtime::IsRunningAsAdmin())
I'm sort of mixed. Did you think of moving to installer selection in case there're other applicable installers? Or it's preferred to tell the user to run non-elevated again since this is what we think is the best installer?
There was a problem hiding this comment.
I think it may be best to have it in the installer, especially given that there is a feature request to filter by elevation requirement. However, if there are no applicable installers based solely on the fact that the user is running in an elevated terminal, then it still should say elevation prohibited rather than no applicable installer found
There was a problem hiding this comment.
I don't think that installer selection is appropriate, we don't even have user intent without #1898. I don't consider "is winget running as admin or not" user intent here, because I want to be able to run my Terminal as user and elevate installers as needed. #1898 should be implemented in installer selection (as well as search) though, because we would have user intent.
|
Side note: I broke VS Code on my machine due to forcing it to install elevated. Be safe out there... |
|
|
||
| // Inform of elevation requirements | ||
| if (!Runtime::IsRunningAsAdmin() && installer->ElevationRequirement == Manifest::ElevationRequirementEnum::ElevatesSelf) | ||
| { |
|
Demitrius Nelon (@denelon) to say if it resolves #152. #271 is more of a general Windows issue; we can't magically bypass the UAC prompt. I don't know how one could even secure a |
I thought that using runas would suppress the prompt, as suggested in the issue; But, perhaps I read it incorrectly or was mistaken |
|
Nope, not having a way to bypass UAC is very much an intentional part of the design |
Fixes #1537, #1538
Change
When
ElevationRequirementis set toelevationProhibitedis set and winget is run elevated, block the installation with an error.When
elevatesSelforelevationRequiredis set and winget is not run elevated, inform the user that an elevation prompt is expected. Also in the case ofelevationRequired, use therunasverb on ShellExecute to run the installer elevated. This can be used on installers that will fail if they are not run elevated.The message is a warning (yellow text) and is the last line below:
Validation
Manually validated each of the 3 elevation requirement options, as automated testing of elevation is not possible on the build server.
Microsoft Reviewers: Open in CodeFlow