gerardog/gsudo

Win32 internal error "Access is denied" 0x5 occurred while reading the console output buffer

neradp opened this issue · 4 comments

neradp commented

The command: gsudo -s add-windowsCapability -Name "Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0" -Online
Powershell 7: OK
WindowsPowershell 5.1: Error

add-windowsCapability : Win32 internal error "Access is denied" 0x5 occurred while reading the console output buffer. C
ontact Microsoft Customer Support Services.
At line:1 char:1
+ add-windowsCapability -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ReadError: (:) [Add-WindowsCapability], HostException
    + FullyQualifiedErrorId : ReadConsoleOutput,Microsoft.Dism.Commands.AddWindowsCapabilityCommand

Running add-windowsCapability elevated by psexec -i -s powershell is ok.

Also running in cmd: gsudo -s powershell add-windowsCapability -Name "Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0" -Online is ok

I have no idea if it is problem with gsudo or WindowsPowershell or DISM commands :(

neradp commented

gsudo -s { Set-Variable ProgressPreference SilentlyContinue; add-windowsCapability -Name "Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0" -Online }

This is the same problem as #180, and as that issue says: the use of 'Set-Variable ProgressPreference SilentlyContinue;' workarounds the problem.
In my system using the workaround fixes the error.... Well, actually I am now getting "Add-WindowsCapability failed. Error code = 0x8024402c", but that is not gsudo's problem since it is the same error I get if I elevate the usual way (without gsudo) and I run the command.

neradp commented

Sorry i was not successful to search for similar previous bug.

Sorry I was not successful to search for similar previous bug.

No worries, and to be honest I don't know a way to solve the problem completely, which may need a fix in Powershell 5.1 which is unprobable. As another workaround: use gsudo --attached {command}