Fix for admin permissions elevation method #3223
Merged
+13
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
I've encountered the same issue in multiple installation of Windows, in pwsh and powershell as described in issue #3099 when trying to run the winutil script:
Testing
I was able to fix this issue by updating the logic for elevation of permissions. Here is a link to my test script for elevation of permissions on GitHub Gist:
emilwojcik93/admin-script.ps1
I even tested this method by editing the winutil script with my updated logic for elevation of permissions, which is demonstrated in the demo video.
emilwojcik93/new-winutil.ps1
Please refer to the provided script and video for a detailed solution to the elevation of permissions issue.
Demo from test
2025-03-02.00-24-03.mp4
2025-03-01.12-45-56.mp4
Impact
Script might startup differently in different kind of terminals/shells (pwsh/powershell/wt)
Issue related to PR
Relaunching as Administrator is not working #3099
Additional Information
I checked this solution only with and without wt.exe with pwsh (powershell 7) and powershell 5. I didn't verify how it's behaving on Win10, nor with additional pass parameters for script (e.g. config file/debug param)
Checklist