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

refactor: windows elevation #51

Merged
merged 8 commits into from
Dec 8, 2023
Merged

refactor: windows elevation #51

merged 8 commits into from
Dec 8, 2023

Conversation

jolexxa
Copy link
Member

@jolexxa jolexxa commented Dec 1, 2023

@AdrasteonDev can you review this? I've refactored the Windows elevation, but I need to run testing on Windows still.

GodotEnv/src/Main.cs Outdated Show resolved Hide resolved
GodotEnv/src/Main.cs Outdated Show resolved Hide resolved
@AdrasteonDev
Copy link
Contributor

AdrasteonDev commented Dec 2, 2023

I don't know if you've been able to test it on Windows, so for information, here's how things work with my PR (without your new modifications).

After a dialog to accept the elevation, a new window opens.

Capture d'écran 2023-12-02 090133

@AdrasteonDev
Copy link
Contributor

AdrasteonDev commented Dec 2, 2023

Unfortunately, the two changes you mentioned above to redirect the output are not possible and throw an exception.

According to the doc:

You must set UseShellExecute to false if you want to set RedirectStandardOutput to true. Otherwise, reading from the StandardOutput stream throws an exception.

I have to set UseShellExecute to true, otherwise the Runas verb is not taken into account.

I tried to hide the new window and redirect the output, without success.

@AdrasteonDev
Copy link
Contributor

AdrasteonDev commented Dec 2, 2023

I've added a commit to this branch for the changes I had to add to your code to make it work. Let me know if you want me to create a pull request to refactor/win-elevation with these changes.

By the way, well done for adding IWindowsElevationEnabled, it's cleaner that way!

@jolexxa
Copy link
Member Author

jolexxa commented Dec 2, 2023

@AdrasteonDev Hey thanks! I did not have time last night to test on Windows, so I'm super grateful for all the help. By all means, open a PR into this branch and we'll get this one fixed with your corrections!

@AdrasteonDev
Copy link
Contributor

I created PR #53 with the change I described

@jolexxa jolexxa linked an issue Dec 7, 2023 that may be closed by this pull request
@jolexxa
Copy link
Member Author

jolexxa commented Dec 7, 2023

@AdrasteonDev Any final changes? If it's looks good to you, we can get this merged and released.

@AdrasteonDev
Copy link
Contributor

It looks good to me, I don't have any additional changes to make. Thanks for the time spent reviewing this PR :)

@jolexxa jolexxa merged commit 686c179 into main Dec 8, 2023
10 checks passed
@jolexxa jolexxa deleted the refactor/win-elevation branch December 8, 2023 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid spamming the elevation prompt on Windows
2 participants