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.28k stars 1.45k forks source link

Can't run winget as a admin #637

Closed Jordan-Mesches closed 3 years ago

Jordan-Mesches commented 4 years ago

Brief description of your issue

I'm trying to avoid the UAC prompt whilst downloading a package, so I open a elevated terminal and run winget

However I get the following message The system cannot execute the specified program.

But note that it works perfectly fine when it's just a normal terminal.

Steps to reproduce

Open an elevated terminal and run winget?

Expected behavior

Winget works normally, except I don't get any UAC prompts when installing

Actual behavior

I get the following output The system cannot execute the specified program.

Environment

[winget --info]
Windows Package Manager v0.2.2521 Preview
Windows: Windows.Desktop v10.0.19041.572
Package: Microsoft.DesktopAppInstaller v1.11.2521.0
haydenhartland commented 2 years ago

Not sure why yours works and mine doesn't. It works fine for me on earlier version but not latest...

29039 commented 2 years ago

I ran into this issue today.

I think that the problem was that I was logged in as a Standard User, and I had run powershell.exe as an Admin user (different username) and that Admin user had not been logged into the Desktop before and therefore never had the opportunity to get winget from the Windows Store.

I think that overall having winget as part of the Microsoft Store & per-user installation is an absolutely horrible idea for a use-case like this, and it would be better to have it baked into Windows itself.

I usually use Chocolatey, which is awesome. But unfortunately there is a particular package which is only on winget (or manual download).

Romanitho commented 2 years ago

Run as system (if you use sccm or intune for example, or via a scheduled task)

Romanitho commented 2 years ago

I have started to work on a process to run everyday to update apps as system and notify connected user https://github.com/Romanitho/Winget-autoupdate i'm not a dev, but it works 😅

KrisAtKingston commented 2 years ago

Winget would be such a usefull tool for system deployment IF it was able to run as system.

Having it Per user based seems such a missed opertunity.

denelon commented 2 years ago

We're working on an In Process COM API the work started with this PR.

It was mentioned in this release.

cgerke commented 1 year ago

We have another "discussion" open that relates to what everyone is getting at here. Ultimately for this to be useful for anything outside of user-managed personal machines, it is an absolute requirement for winget to be deployable to the system context (i.e. msi or exe, binaries installed to a protected folder like \program files or \windows\system32). Right now we get that using the MSIX delivery mechanism is the newer method and it makes this manageable via the MS Store, but it makes it completely unusable for businesses entirely.

My testing thus far with Winget has me hopeful on how useful this tool can be for installing and updating applications by simply updating manifests in our eventual private repository. Right now though, this tooling is entirely run in the user context, therefore completely unusable as it requires every user on a machine to have this installed, and then requires them be granted administrative permissions on the machine to execute the installers defined in the app manifests. Given today's security landscape and the various breaches in the past 6 months alone, I see many business partners locking things down and controlling administrative access much more tightly, so having this tooling available under the "system" context is going to be critical towards gaining adoption beyond home users and hobbyists.

Here is a link to our other discussion regarding this: #962

Some interesting stats on the manifests doing a search of InstallerType across the git repo.

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

secprentice commented 1 year ago

MS needs to make winget work at a system level. As per everyone's comments in: https://github.com/microsoft/winget-cli/discussions/962

aclondon commented 8 months ago

Appreciate this is a slightly old topic, but if you are running winget using an elevated command prompt, such as:

runas /user:localadmin cmd - this will not work.

You need to use

runas /noprofile /user:localadmin cmd

A bit more details here https://superuser.com/questions/42537/is-there-any-sudo-command-for-windows