Here’s how to run Windows Terminal profiles (Command Prompt & PowerShell) in elevated mode without having to run Windows Terminal as Administrator. To do so, we will use a nifty package manager named
[Chocolatey](<https://chocolatey.org/install>) in order to install
gsudo is a
sudo equivalent for Windows, with a similar user-experience as the original Unix/Linux
sudo. It allows to run commands with elevated permissions, or to elevate the current shell, in the current console window or a new one. We will then leverage this tool to open Windows Terminal profiles with elevated privileges.
PowerShell as Administrator and make sure the
ExecutionPolicy allows installation:
If the output of the above command is
Restricted , run the following to allow scripts to run:
> Set-ExecutionPolicy AllSigned
Chocolatey by issuing the following:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('<https://community.chocolatey.org/install.ps1>'))
Finally, run the following to install
choco install gsudo -y
Now launch Windows Terminal as you would normally do, go to Settings and on the left pane click Add a new profile
You can either create a new empty profile or duplicate an existing one. I prefer to duplicate, so I will duplicate my Windows PowerShell profile
This will create a new profile Windows PowerShell (Copy). Go ahead and rename this profile to whatever you desire.
Under the Command Line field, simply prepend gsudo to the executable:
Save this new profile and open a new tab with the new profile and… TADAAAAA! 🎉
You will now be prompted to run PowerShell as admin.
This procedure can be repeated with the Command Prompt profile, using
gsudo cmd.exe as its command line.
If you found this helpful, please feel free to…