Skip to content

[BUG] System.InvalidOperationException UniGetUI Elevator.exe -- Regression from #3913 #4579

@BartJolling

Description

Please confirm these before moving forward

  • I have searched for my issue and have not found a work-in-progress/duplicate/resolved issue.
  • I have tested that this issue has not been fixed in the latest (beta or stable) release.
  • I have checked the FAQ section for solutions.
  • This issue is about a bug (if it is not, please use the correct template).

UniGetUI Version

2026.1.4

Windows version, edition, and architecture

Windows 11 Pro 25H2

Describe your issue

I had already reported and solved this issue in #3913. Looks like my fix was lost? See my PR: Devolutions/GSudo-for-UniGetUI#4

Trigger: My PC is a corporate laptop that has AdminByRequest.exe installed.

The root cause is that public static Process StartElevatedDetached(string filename, string arguments, bool hidden) returns a Process object, and the object is used to get SafeProcessHandle so that the StartService function can return it.

However, when AdminByRequest.exe is installed, the Process object points to AdminByRequest and not to Uniget. And by the time you try to get the SafeProcessHandle, the AdminByRequest has already exited.

Fortunately, these handles are never used - so the fix was simply to stop returning the Process object and the SafeHandles.

The other part of the solution was to add the certificate subject of AdminByRequest to the Uniget Elevator so that it passes the integrity checks.

But please review the original pull request and apply the same fixes

Package install operation for Package=JGraph.Draw with Manager=Winget
Installation options: <InstallOptions instance (only non-default values are shown)
	OverridesNextLevelOpts: False>
Overriden options: <Scope=;RunAsAdministrator=;WG_SpecifyVersion=;PS_NoScope=False;Pip_BreakSystemPackages=False>
Starting operation...
Executing process with StartInfo:
 - FileName: "C:\Users\BartJolling\AppData\Local\Programs\WingetUI\Assets\Utilities\UniGetUI Elevator.exe"
 - Arguments: ""C:\Users\BartJolling\AppData\Local\Microsoft\WindowsApps\winget.exe"  install --id "JGraph.Draw" --exact --source winget --accept-source-agreements --disable-interactivity --silent --accept-package-agreements --force"
Start Time: "13/04/2026 15:51:48"
Error: System.InvalidOperationException: No process is associated with this object.
at System.Diagnostics.Process.EnsureState(Process.State) + 0x1ed
at gsudo.Helpers.ServiceHelper.StartService(Nullable`1, Nullable`1, String, Boolean) + 0x7c5
at gsudo.Commands.RunCommand.<RunUsingService>d__8.MoveNext() + 0x724
--- End of stack trace from previous location ---
at gsudo.Commands.RunCommand.<Execute>d__6.MoveNext() + 0xe5
--- End of stack trace from previous location ---
at gsudo.Program.<Start>d__1.MoveNext() + 0x19a
End Time: "13/04/2026 15:52:17"
Process return value: "999" (0x3E7)
draw.io could not be installed

Steps to reproduce the issue

#3913
Install AdminByRequest, perform an installation that requires elevation

UniGetUI Log

https://github.com/Devolutions/UniGetUI/issues/3913

Package Managers Logs

https://github.com/Devolutions/UniGetUI/issues/3913

Relevant information

#3913

Screenshots and videos

#3913

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions