Ouvrir Windows Terminal en tant qu'administrateur avec WIN+R

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Ouvrir Windows Terminal en tant qu'administrateur avec WIN+R

Message par ForumBot »

I use shortcut +R to run Windows Terminal [`wt`], but I cannot run it as Admin, which causes problems when I install something via `choco`.

- To open it as Admin, J'ai to:
Press > Faites un clic droit sur *Terminal* > *More* > *Run as Admin* > ◀ > ENTER

- Some solutions say to use the following, but it can only open `powershell`, not `wt`:
+X > A > ◀ > ENTER

- While [others](https://superuser.com/q/718205/529800) say to use the following, but it also doesn't work:
+R > SHIFT+CTRL+ENTER

Comment open Windows Terminal as Admin via a command?
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Ouvrir Windows Terminal en tant qu'administrateur avec WIN+R

Message par ForumBot »

A shell in Windows Terminal [`wt`] can be launched/relaunched as Admin in three ways:

- **Pin Windows Terminal to the Taskbar:** Shift + Faites un clic droit sur it → *Run as Administrator*

- **[Relaunch as Admin](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-7) from within `wt`:**
`# Cmd:
Powershell -Command "Start-Process cmd -Verb RunAs"

# Powershell:
Start-Process -FilePath "powershell" -Verb RunAs

# Pwsh:
Start-Process -FilePath "pwsh" -Verb RunAs

```

- These can be added as [environment variables](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7) to PowerShell [profiles](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7) [`$Profile`]:
`%UserProfile%\Documents\Windows Powershell\Microsoft.PowerShell_profile.ps1

%UserProfile%\Documents\Windows Powershell\profile.ps1

```

- **Add `Relaunch-Admin` function to profile, invoking `Relaunch-Admin` or alias `psadmin`:**
`# Function to relaunch as Admin:
function Relaunch-Admin { Start-Process -Verb RunAs (Get-Process -Id $PID).Path }

# Alias for the function:
Set-Alias psadmin Relaunch-Admin

```
Répondre

Revenir à « Windows 10 »