Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run winget.exe: "Access is denied" #1328

Closed
rasa opened this issue Jul 28, 2021 · 15 comments
Closed

Can't run winget.exe: "Access is denied" #1328

rasa opened this issue Jul 28, 2021 · 15 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation.
Milestone

Comments

@rasa
Copy link

rasa commented Jul 28, 2021

Brief description of your issue

Typing:
c:\> winget
returns
Access is denied

I can run winget logged in as the original local administrator user. It's failing when I login as a different user who's also an local adminstrator. I've tried resetting the rights to winget.exe using takeout and icalcs /reset /c /q, but that didn't help. I've uninstalled/reinstalled it several times, but nothing helps. Can't the installer reset the rights, so it just works?

Steps to reproduce

See above.

Expected behavior

winget runs without reporting errors

Actual behavior

See above

Environment

Windows 10 x64 10.0.19042

@ghost ghost added the Needs-Triage Issue need to be triaged label Jul 28, 2021
@KevinLaMS KevinLaMS added Issue-Bug It either shouldn't be doing this or needs an investigation. and removed Needs-Triage Issue need to be triaged labels Jul 28, 2021
@KevinLaMS
Copy link
Contributor

Sorry to hear that.
Can you verify what WHERE returns?
Example:
C:\Users\kevinla\source\repos\winget-cli-restsource\documentation\guide>where winget
C:\Users\kevinla\AppData\Local\Microsoft\WindowsApps\winget.exe

My guess is you may not have read permission which seems odd.
Can you see the files in that folder?
Example: dir C:\Users<YOUR PATH>\AppData\Local\Microsoft\WindowsApps\

Can you run the following and provide me the output?
powershell Get-AppxPackage microsoft.DesktopAppInstaller

Finally, while we are digging into this, feel freed to file a feedback hub issue as this will produce LOGS I can make a dev look at.

@denelon denelon added the Needs-Author-Feedback Issue needs attention from issue or PR author label Aug 4, 2021
@ghost ghost added the No-Recent-Activity Issue has no recent activity label Aug 11, 2021
@ghost
Copy link

ghost commented Aug 11, 2021

@rasa this issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@denelon denelon added this to WinGet Oct 1, 2021
@denelon denelon added this to the v1.2-Client milestone Oct 1, 2021
@ghost ghost removed the No-Recent-Activity Issue has no recent activity label Oct 1, 2021
@ghost ghost added the No-Recent-Activity Issue has no recent activity label Oct 9, 2021
@ghost
Copy link

ghost commented Oct 9, 2021

@rasa this issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@pefoley2
Copy link

pefoley2 commented Oct 9, 2021

I'm hitting an identical issue:
C:\Users\jfole>winget
Access is denied.

where winget
C:\Users\jfole\AppData\Local\Microsoft\WindowsApps\winget.exe

dir C:\Users\jfole\AppData\Local\Microsoft\WindowsApps
Volume in drive C has no label.
Volume Serial Number is 7439-9EA9

Directory of C:\Users\jfole\AppData\Local\Microsoft\WindowsApps

10/09/2021 11:41 AM

Backup
10/02/2021 10:30 PM 0 GameBarElevatedFT_Alias.exe
10/09/2021 11:36 AM Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
06/08/2021 11:37 PM Microsoft.MicrosoftEdge_8wekyb3d8bbwe
08/13/2021 06:43 PM Microsoft.SkypeApp_kzf8qxf38zg5c
10/09/2021 11:41 AM Microsoft.WindowsTerminal_8wekyb3d8bbwe
10/02/2021 10:30 PM Microsoft.XboxGamingOverlay_8wekyb3d8bbwe
04/15/2021 01:11 AM 0 MicrosoftEdge.exe
10/09/2021 11:36 AM 0 python.exe
10/09/2021 11:36 AM 0 python3.exe
08/13/2021 06:43 PM 0 Skype.exe
10/01/2021 05:00 PM 0 Spotify.exe
10/01/2021 05:00 PM SpotifyAB.SpotifyMusic_zpdnekdrzrea0
10/09/2021 11:36 AM 0 winget.exe
10/09/2021 11:41 AM 0 wt.exe
8 File(s) 0 bytes
7 Dir(s) 395,438,116,864 bytes free

powershell Get-AppxPackage microsoft.DesktopAppInstaller

Name : Microsoft.DesktopAppInstaller
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X64
ResourceId :
Version : 1.16.12653.0
PackageFullName : Microsoft.DesktopAppInstaller_1.16.12653.0_x64__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.16.12653.0_x64__8wekyb3d8bbwe
IsFramework : False
PackageFamilyName : Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
Dependencies : {Microsoft.VCLibs.140.00.UWPDesktop_14.0.30035.0_x64__8wekyb3d8bbwe,
Microsoft.DesktopAppInstaller_1.16.12653.0_neutral_split.scale-100_8wekyb3d8bbwe}
IsPartiallyStaged : False
SignatureKind : Store
Status : Ok

Feedback Hub report filed: https://aka.ms/AAe01u7

@ghost ghost removed the No-Recent-Activity Issue has no recent activity label Oct 9, 2021
@denelon denelon removed the Needs-Author-Feedback Issue needs attention from issue or PR author label Oct 11, 2021
@denelon denelon moved this from Assigned to To Do in WinGet Oct 19, 2021
@denelon
Copy link
Contributor

denelon commented Oct 26, 2021

@rasa have you taken a look at our troubleshooting steps? We've recently added a section with some PowerShell commands that may help resolve the issue.

@JohnMcPMS
Copy link
Member

@pefoley2, I know it has been a while, but from your feedback logs it looks like an issue in the OS itself. I have forwarded to the correct team. Rebooting should resolve the issue if you encounter it again (and yes, I know how that sounds coming from a Microsoft employee 😄 ).

@rasa
Copy link
Author

rasa commented Nov 18, 2021

I still have this issue. The troubleshooting steps did not help. Additionally, on a different Windows 10 Pro x64 fully patched system, I have been getting
The system cannot execute the specified program.
for several weeks. Reinstalling doesn’t help. Rebooting doesn’t help.

@denelon denelon modified the milestones: v1.2-Client, v1.3-Client Jan 8, 2022
@denelon denelon modified the milestones: v1.3-Client, v1.4-Client May 31, 2022
@denelon
Copy link
Contributor

denelon commented Aug 8, 2022

@rasa we've released Windows Package Manager 1.3.

Is this still happening?

@denelon denelon added the Needs-Author-Feedback Issue needs attention from issue or PR author label Aug 8, 2022
@rasa
Copy link
Author

rasa commented Aug 8, 2022

I gave up fighting installing winget months ago. I spent many many hours, but couldn't work around the access denieds and The system cannot execute the specified program.s, even after multiple rounds of rebooting, uninstalling and reinstalling. The troubleshooting steps were no help either. On multiple systems too.

Now, I simply type scoop install winget, and I never have issues. For reference, Scoop installs winget via:
https://github.com/ScoopInstaller/Main/blob/0bc53dd323e6789594032997d6ca0e91c4220f5d/bucket/winget.json#L23

I find it ironic that I had to use another packaging tool to successfully use this packaging tool. Hopefully 1.3 has addressed these issues. I will leave this issue open as others are feeling my pain, but feel free to close it, as I've moved on.

(Full disclosure: I am a scoop maintainer)

@ghost ghost added Needs-Attention Issue needs attention from Microsoft and removed Needs-Author-Feedback Issue needs attention from issue or PR author labels Aug 8, 2022
@denelon
Copy link
Contributor

denelon commented Aug 8, 2022

@rasa thanks for responding!

The irony isn't lost on me either. We've had quite a few challenges working through the incantations to get everything working correctly. There have been a mixture of issues related to the fact that winget is delivered via App Installer and we're currently depending on an update from the store. This problem should gradually go away with newer updates to both App Installer and Windows.

I'm going to go ahead and close this, but the history will be preserved for others to find. Also, it's worth noting MSIX packages aren't available to system context calls. They were designed to be registered upon interactive login, and our path forward for system / remote execution is via a COM API we're developing as a part of the Integration for Intune, third-party MDM providers, and the native PowerShell implementation.

@alinaimi
Copy link

You likely have multiple instances of winget.exe in your system’s $PATH. To resolve this, consider cleaning up your PATH variable or directly calling the correct executable file "%LOCALAPPDATA%\Microsoft\WindowsApps\winget.exe"

@rasa
Copy link
Author

rasa commented Dec 18, 2023

You likely have multiple instances of winget.exe in your system’s $PATH.

@alinaimi In my case, I didn't, but that might help others who encounter this issue.

@twglomski
Copy link

Since I stumbled on this while trying to automate install of .NET runtimes, I'll throw in the research I found:

Right after installing winget I was getting the Access is denied error (On Server 2022). I would try a few things, and after a while the error would go away and work normally.

This seemed strange to me as there were troubleshooting steps I would try and it would work, and when I'd try them again they wouldn't work. So I wrote a loop to attempt opening winget every 5 seconds to see if after a certain amount of time the error would go away. It turns out it did - 10 to 15 minutes after the initial install.

I checked in the Event Log to attempt to correlate this to any service starts, and I noticed the AppX Deployment service restarted right before the error went away. I tried restarting that service after install but that didn't work - only time seemed to resolve this.

IDK if this would be helpful for anyone finding this in the future. I will note that @rasa 's suggestion of using Scoop worked flawlessly. (Turned out that I didn't need the .NET runtimes, but rather the .NET web hosting pack, which I couldn't find on winget and ended up using Chocolatey for my install.)

The script I used to install, then loop over running winget until it magically started working:

Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.7.3/Microsoft.UI.Xaml.2.7.x64.appx -OutFile Microsoft.UI.Xaml.2.7.x64.appx
Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v1.6.3482/24146eb205d040e69ef2d92d7034d97f_License1.xml -OutFile 24146eb205d040e69ef2d92d7034d97f_License1.xml
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage Microsoft.UI.Xaml.2.7.x64.appx
Add-AppxProvisionedPackage -Online -PackagePath Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle  -LicensePath 24146eb205d040e69ef2d92d7034d97f_License1.xml -dependencypackagepath Microsoft.VCLibs.x64.14.00.Desktop.appx
$ResolveWingetPath = (Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe").Path

$then = get-date; $erroraction = 'silentlyContinue'; do {start-sleep -seconds 5;$wgr = . $resolvewingetpath\winget.exe} while (!$wgr);$now=get-date; $elapsed = $now-$then;write-output "Took $($elapsed.minutes) minutes and $($elapsed.seconds) seconds for WinGet to work. Started working at $($now)"

@fluidum
Copy link

fluidum commented Jan 24, 2024

Thank you @twglomski !

Your script lines helped getting my winget working on Windows Server 2022 Standard 21H2 (20348.2227), winget v1.6.3482

The system cannot execute the specified program.

@denelon denelon removed the Needs-Attention Issue needs attention from Microsoft label Jul 29, 2024
@marioqxx
Copy link

I had the same problem. Deleting folder \Users<user>\AppData\Local\Temp\Winget - which for whatever reason had only Administrator-access-rights as descibed here:

#4704 (comment)

solved the problem for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
Archived in project
Development

No branches or pull requests

9 participants