Skip to content

System Context #3049

Description

@cgerke

Description of the new feature / enhancement

This really shouldn't be moved to a discussion.

Not having the option to run winget in the System Context will essentially stop most organisations using winget. Zero Trust is a framework that more and more organisations will be adopting. Local admin rights is a dinosaur.

Some interesting stats with the winget-pkgs manifests, doing a search of InstallerType across the git repo show that msix is really a small component of what people are installing with the winget tool.

11940 results in 11134 files InstallerType: nullsoft (exe)
6318 results in 4855 files InstallerType: wix (msi)
5931 results in 5387 files InstallerType: inno
5664 results in 3754 files InstallerType: exe
2713 results in 1974 files InstallerType: msi
1004 results in 637 files InstallerType: burn (exe)
811 results in 688 files InstallerType: portable
448 results in 290 files InstallerType: msix
225 results in 217 files InstallerType: zip

Proposed technical implementation details

It's possible to run winget in the system context already, the sample code is below.

All I'm asking is for the winget-cli development team to recognise this, ensure this is a support method of running it, by simply taking this use case into consideration when developing winget further to ensure this type of usage does not break anything.

Possibly even ensure the system context executable is added to the machine PATH environment variable.

#region CODE
$winget = $null
$DesktopAppInstaller = "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
$SystemContext = Resolve-Path "$DesktopAppInstaller"
if ($SystemContext) { $SystemContext = $SystemContext[-1].Path }
$UserContext = Get-Command winget.exe -ErrorAction SilentlyContinue
if ($UserContext) { $winget = $UserContext.Source }
elseif (Test-Path "$SystemContext\AppInstallerCLI.exe") { $winget = "$SystemContext\AppInstallerCLI.exe" }
elseif (Test-Path "$SystemContext\winget.exe") { $winget = "$SystemContext\winget.exe" }
else { return $false }
if ($null -ne $winget) { $winget }
# Logs $(env:LOCALAPPDATA)\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
& "$winget" install --id "7zip.7zip" --exact --silent --accept-source-agreements --accept-package-agreements | Out-String
#endregion

Metadata

Metadata

Assignees

No one assigned

    Labels

    Context-SystemRelated to system context (nt authority/session 0)Issue-DocsIt's a documentation issue that really should be on MicrosoftDocsIssue-FeatureThis is a feature request for the Windows Package Manager client.Needs-Author-FeedbackIssue needs attention from issue or PR authorPowerShellIssue related to WinGet PowerShell Module or cmdlet
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions