<p>Un shell dans Windows Terminal [<code>wt</code>] peut être lancé/relancé en tant qu’administrateur de trois manières :</p>
<ul>
<li>
<p><strong>Épinglez Windows Terminal à la barre des tâches :</strong> Maj + Clic droit dessus → <em>Exécuter en tant qu’administrateur</em></p>
</li>
<li>
<p><strong><a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-7">Relancer en tant qu’administrateur</a> depuis <code>wt</code> :</strong><br>
`# Cmd:<br>
Powershell -Command “Start-Process cmd -Verb RunAs”</p>
</li>
</ul>
<h1><a name="p-26900-powershell-1" class="anchor" href="#p-26900-powershell-1" aria-label="Heading link"></a>Powershell:</h1>
<p>Start-Process -FilePath “powershell” -Verb RunAs</p>
<h1><a name="p-26900-pwsh-2" class="anchor" href="#p-26900-pwsh-2" aria-label="Heading link"></a>Pwsh:</h1>
<p>Start-Process -FilePath “pwsh” -Verb RunAs</p>
<pre><code class="lang-auto">
- Ceux-ci peuvent être ajoutés comme variables d'environnement aux profils PowerShell [
$Profile] :
`%UserProfile%\Documents\Windows Powershell\Microsoft.PowerShell_profile.ps1
%UserProfile%\Documents\Windows Powershell\profile.ps1
</code></pre>
<ul>
<li><strong>Ajoutez la fonction <code>Relaunch-Admin</code> au profil, en invoquant <code>Relaunch-Admin</code> ou l’alias <code>psadmin</code> :</strong><br>
`# Fonction pour relancer en tant qu’administrateur :<br>
function Relaunch-Admin { Start-Process -Verb RunAs (Get-Process -Id $PID).Path }</li>
</ul>
<h1><a name="p-26900-alias-pour-la-fonction-3" class="anchor" href="#p-26900-alias-pour-la-fonction-3" aria-label="Heading link"></a>Alias pour la fonction :</h1>
<p>Set-Alias psadmin Relaunch-Admin</p>
<pre><code class="lang-auto"></code></pre>