-1

It happens again and again that I am in a Powershell session and want to execute a command for which I need admin (elevated) rights.

My current workflow then:

1. pwd (ctrl+c)
2. open a new Powershell (run as administrator)
3. cd ctrl+v

This is very annoying and time-consuming, how can I optimise this?

Cowas
  • 328
  • 2
  • 12
  • Does this answer your question? [How to create a Run As Administrator shortcut using Powershell](https://stackoverflow.com/questions/28997799/how-to-create-a-run-as-administrator-shortcut-using-powershell) – JosefZ Sep 03 '20 at 14:03

2 Answers2

2

I guess the standard way of creating a shortcut should do it:

  • In a command box type where wt.exe to get the file path.
    This will most probably return C:\Users\<yourname>\AppData\Local\Microsoft\WindowsApps\wt.exe
  • Open the path and right-click wt.exe (eventhough in there it shows 0 kb)
  • Select 'Create Shortcut'
  • Right-click the new shortcut and in the General tab change the name to Windows Terminal (Admin)
  • In the Shortcut tab, click the Advanced button and check the box "Run as administrator"
  • click OK
  • Drag the shortcut to your desktop
Theo
  • 57,719
  • 8
  • 24
  • 41
0

Theo's answer didn't work for me, but this one did. Copied:

  1. Right click -> New -> Shortcut Type in C:\Windows\System32\cmd.exe /c start /b %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\wt.exe for the location

  2. Give whatever name you want to give, finish.

  3. List item

  4. Right click on the newly created shortcut -> Properties -> Advanced -> Run as administrator