Skip to content

Improvements for User vs. Machine #965

Closed
Closed

Description

Description of the new feature/enhancement

The Windows Package Manager needs work per-installer type to determine if we can dynamically specify scope to the underlying installer. For instance, MSI supports specifying it, as well as embedding the value. And MSIX can be installed for the machine, but requires additional code to convert the user install to a machine install.

So for each type, we need to understand:

  1. Are there command line options that let us choose the scope dynamically?
  2. Is there metadata embedded in the installer that will tell us the scope?
  3. If 2, can it be overridden or would that lead to a dysfunctional package?

With this we could then improve the default behaviors, as currently we don't allow unknown scopes to meet the requirement of a particular given one.

Proposed technical implementation details (optional)

Activity

  1. added
    Issue-Feature
    on May 14, 2021
  2. ghost added
    Needs-Triage
    on May 14, 2021
  3. jedieaston commented on May 14, 2021

    @jedieaston
    Contributor

    For 2, one way that could be found for exe installers could come from whether or not the installer returns a successful error code if it is ran via a non-admin user account (the environment variable __COMPAT_LAYER=RunAsInvoker tells Windows not to ask for UAC elevation, so if you aren't running as Administrator or SYSTEM, it'd suffice).

    For MSIs, the ALLUSERS property in the database seems to control it. If it is equal to "" or 2, it will install for a single user, if it is set to 1, the MSI can only be installed for the entire machine. https://docs.microsoft.com/en-us/windows/win32/msi/allusers

    I'm beginning to think there's going to be a need for a set of tests for manifests to check all of the different scenarios.

  4. denelon commented on May 14, 2021

    @denelon
    CollaboratorAuthor

    Easton Pillay (@jedieaston) I agree. As we move forward, many of these scenarios will need additional automated testing. Our validation processes are fairly long running, so we're looking at how we might be able to run some of these tests in parallel to keep processing time to a reasonable minimum.

  5. Jaifroid commented on Jun 5, 2021

    @Jaifroid

    Are the NSIS commandline switches /AllUsers vs /CurrentUser supported "out of the box" for this feature, or do they have to be specified somehow in the manifest?

  6. denelon commented on Jun 7, 2021

    @denelon
    CollaboratorAuthor

    Jaifroid (@Jaifroid) we have more work to do for "User" vs. "Machine". The current list of "InstallerTypes" we commonly allow the client to support without switches doesn't have "NSIS", but some installers have evolved over time.

  7. Jaifroid commented on Jun 7, 2021

    @Jaifroid

    Demitrius Nelon (@denelon) NSIS = Nullsoft Scriptable Install System, so you do in principle support it with the key nullsoft.

  8. denelon commented on Jun 7, 2021

    @denelon
    CollaboratorAuthor

    Jaifroid (@Jaifroid)
    Yes, but we haven't performed enough testing across "nullsoft" installers (or any other .exe based installers) to have confidence in consistent behavior with "User" vs. "System".

  9. github-account1111 commented on Apr 10, 2022

    @github-account1111

    If I specify scope as machine, and no scope selection is available for a package, what will happen?
    As is, there is no way to predetermine whether a package supports selection, so, in a script, would I just add --scope machine to every package regardless?

  10. denelon commented on Apr 11, 2022

    @denelon
    CollaboratorAuthor

    github-account1111,

    The default behavior when scope is specified is to go with user unless machine is specified. We may need to add some kind of "supported scopes" or "package default scope" to the schema for this scenario.

  11. github-account1111 commented on Apr 11, 2022

    @github-account1111

    when scope is specified

    You mean specified by the manifest, not the user, correct?
    So if I specify machine but no machine is available it will not error out?

  12. denelon commented on Apr 11, 2022

    @denelon
    CollaboratorAuthor

    The manifest supports specifying scope for a given installer. Sometimes this is managed by passing arguments to the installer.

    If both user and machine are specified in the manifest, the client will default to user (unless an argument or settings changes the default behavior).

    If the manifest has no information about the scope of the installer, it is just executed as specified in the manifest (or by switches passed by the user).

    Different .exe-based installers may behave differently than expected. The scenario you are mentioning would depend on how the manifest is configured, and the installer itself.

  13. github-account1111 commented on May 2, 2022

    @github-account1111

    If the manifest has no information about the scope of the installer, it is just executed as specified in the manifest (or by switches passed by the user).

    I've just tested and that is not the case:

    winget install `
    	--id OpenWhisperSystems.Signal `
    	--scope machine `
    	--accept-package-agreements
    

    That errors out with:

    [CLI ] Installer [X64,nullsoft,User,] not applicable: Installer scope does not match required scope: User != Machine
    [CLI ] Terminating context: 0x8a150010 at D:\a\_work\1\s\external\pkg\src\AppInstallerCLICore\Workflows\InstallFlow.cpp:74
    
  14. github-account1111 commented on Jul 15, 2022

    @github-account1111

    Another scenario in favor of not erroring out if machine is specified but not currently available for a package:
    If a package that did not support the machine scope previously, but does eventually, the user will have no way of knowing (unless they manually check all the manifests on a regular basis which practically defeats the purpose of using a package manager).
    OTOH they could just specify machine from the get-go, and the package will just be installed in user until machine support is added.

  15. denelon commented on Jul 27, 2026

    @denelon
    CollaboratorAuthor

    The scope-handling framework this issue called for has been implemented.

    Dynamic scope selection

    • winget install --scope user|machine selects scope at the command line.
    • Settings provide a persistent preference (installBehavior.preferences.scope) and a hard requirement (installBehavior.requirements.scope); command-line --scope overrides settings.

    Scope matching and defaults

    • A dedicated scope comparator filters and ranks installers: a requirement must be satisfied, a preference is applied best-effort with tie-breaking. This drives the default installer selection.
    • The original concern - that an unknown installer scope couldn't satisfy a given requirement - is addressed: unknown scope can be explicitly allowed to meet a requirement, and for upgrade unknown scope is treated as a match so existing installs keep working.

    Per-installer-type handling
    WinGet now distinguishes types whose scope it can control directly (Font, Portable, MSIX, MSStore) from Win32 types that carry scope in the manifest/installer switches:

    • Win32 - per-user vs. machine-wide via the installer's own mechanism (e.g., MSI ALLUSERS); machine-scope installs are gated on elevation.
    • MSIX - user scope registers the package per-user; machine scope provisions and registers it for all users.

    Out of scope here: the remaining system-context gaps for MSIX are a Windows platform limitation being worked on by the MSIX team - not something WinGet can resolve in this issue.

    Closing as completed now that the scope framework and per-type behaviors are in place. If a specific installer type still mis-detects or mis-applies scope, please open a new, targeted issue with the package details.

    (Drafted with GitHub Copilot assistance.)

  16. beedell-roke commented on Jul 27, 2026

    @beedell-roke

    Demitrius Nelon (@denelon), I am a lay man, so does that mean that the suggestion, that #issuecomment-1185795000 specifies, has been remediated? Additionally, what MSIX "system context" do you refer to? The immediate context does not appear to explain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Feature

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions