Skip to content

Commit

Permalink
Handle canceled UAC prompts as "Operation canceled by user" instead o…
Browse files Browse the repository at this point in the history
…f "Error"
  • Loading branch information
marticliment committed Sep 16, 2024
1 parent 0333696 commit 4ff3486
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,24 @@ public string[] GetRemoveSourceParameters(IManagerSource source)
public OperationVeredict GetAddSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output)
{
AssertSourceCompatibility("GetAddSourceOperationVeredict");

if (ReturnCode is 999 && Output.Last() == "Error: The operation was canceled by the user.")
{
Logger.Warn("Elevator [or GSudo] UAC prompt was canceled, not showing error message...");
return OperationVeredict.Canceled;
}
return SourceProvider.GetAddSourceOperationVeredict(source, ReturnCode, Output);
}

public OperationVeredict GetRemoveSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output)
{
AssertSourceCompatibility("GetRemoveSourceOperationVeredict");

if (ReturnCode is 999 && Output.Last() == "Error: The operation was canceled by the user.")
{
Logger.Warn("Elevator [or GSudo] UAC prompt was canceled, not showing error message...");
return OperationVeredict.Canceled;
}
return SourceProvider.GetRemoveSourceOperationVeredict(source, ReturnCode, Output);
}

Expand Down Expand Up @@ -442,6 +455,12 @@ public OperationVeredict GetOperationResult(IPackage package, OperationType oper
{
try
{
if (returnCode is 999 && processOutput.Last() == "Error: The operation was canceled by the user.")
{
Logger.Warn("Elevator [or GSudo] UAC prompt was canceled, not showing error message...");
return OperationVeredict.Canceled;
}

return OperationProvider.GetOperationResult(package, operation, processOutput, returnCode);
}
catch (Exception ex)
Expand Down

0 comments on commit 4ff3486

Please sign in to comment.