Skip to content

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

Closed

Description

@rasa

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

Activity

  1. ghost added
    Needs-Triage
    on Jul 28, 2021
  2. added
    Issue-Bug
    and removed
    Needs-Triage
    on Jul 28, 2021
  3. KevinLaMS commented on Jul 28, 2021

    @KevinLaMS
    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.

  4. added
    Needs-Author-Feedback
    on Aug 4, 2021
  5. ghost added
    No-Recent-Activity
    on Aug 11, 2021
  6. ghost removed
    No-Recent-Activity
    on Oct 1, 2021
  7. ghost added
    No-Recent-Activity
    on Oct 9, 2021
  8. pefoley2 commented on Oct 9, 2021

    @pefoley2

    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

  9. ghost removed
    No-Recent-Activity
    on Oct 9, 2021
  10. 9 remaining items

  11. denelon commented on Aug 8, 2022

    @denelon
    Collaborator

    Ross Smith II (@rasa) we've released Windows Package Manager 1.3.

    Is this still happening?

  12. added
    Needs-Author-Feedback
    on Aug 8, 2022
  13. rasa commented on Aug 8, 2022

    @rasa
    Author

    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)

  14. ghost added
    Needs-Attention
    on Aug 8, 2022
  15. ghost removed
    Needs-Author-Feedback
    on Aug 8, 2022
  16. denelon commented on Aug 8, 2022

    @denelon
    Collaborator

    Ross Smith II (@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.

  17. alinaimi commented on Dec 18, 2023

    @alinaimi

    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"

  18. rasa commented on Dec 18, 2023

    @rasa
    Author

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

    Alireza Naimi, PhD, PE (@alinaimi) In my case, I didn't, but that might help others who encounter this issue.

  19. twglomski commented on Jan 23, 2024

    @twglomski

    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 Ross Smith II (@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)"
    
  20. fluidum commented on Jan 24, 2024

    @fluidum

    Thank you Ted Glomski (@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.

  21. removed
    Needs-Attention
    on Jul 29, 2024
  22. marioqxx commented on Sep 10, 2024

    @marioqxx

    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.

  23. Destroyer commented on Jan 25, 2025

    @Destroyer

    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)"
    

    this is not perfect, e.g. with version 1.9.25200 you should download
    Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle , 7fdfd40ea2dc40deab85b69983e1d873_License1.xml and DesktopAppInstaller_Dependencies.zip from releases assets
    unzip dependencies for your architecture and install those appx via Add-AppxPackage
    then add DesktopAppInstaller itself

    only then you can be sure that you have matching dependencies with winget itself (I had issue with it just now)

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-Bug

    Type

    No type

    Projects

    • Status
      Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions