Persistent path for Open Windows Terminal in current folder as admin

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
Gorazd
Junior Member
Junior Member
Posts: 13
Joined: 2021-07-09, 23:01 UTC

Persistent path for Open Windows Terminal in current folder as admin

Post by *Gorazd »

Hello everybody,

I have the following problem:
I was able to put together a shortcut for TC, which allows me to open Windows Terminal command prompt in a given folder as an admin:

Command: *"%ProgramFiles%\WindowsApps\Microsoft.WindowsTerminal_1.15.3465.0_x64__8wekyb3d8bbwe\wt.exe"
Parameters: nt -d %P
Icon file: C:\Praca\Zaloha\wallpapers\icons\Terminal.ico
Tooltip: Open WT in current folder as admin

It is working, but I have one problem: every time the app updates, the version number ("1.15.3465.0" part of the string), will change and I have to modify it after some time.
Is there any way that I can put there a path which I wouldn´t have to change after every WinTerminal update?

Help with this would be appreciated.
Thanks.
Fla$her
Power Member
Power Member
Posts: 2998
Joined: 2020-01-18, 04:03 UTC

Re: Persistent path for Open Windows Terminal in current folder as admin

Post by *Fla$her »

Command: *%ComSpec% /q/c for /f tokens^=* %f in ('dir/a-d/b/s "%ProgramFiles%\WindowsApps\wt.exe"') do @start "" "%f" nt -d
Parameters: "%P"
Overquoting is evil! 👎
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Persistent path for Open Windows Terminal in current folder as admin

Post by *white »

Copy and paste this on you button bar.

Code: Select all

TOTALCMD#BAR#DATA
*"%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe" nt -d
"%P\"
imageres.dll,263
Run WindowsTerminal as administrator


-1
I added an extra backslash after %P because on my system WindowsTerminal would otherwise interpret the trailing backslash of %P together with the quote at the end as a literal quote.
User avatar
Gorazd
Junior Member
Junior Member
Posts: 13
Joined: 2021-07-09, 23:01 UTC

Re: Persistent path for Open Windows Terminal in current folder as admin

Post by *Gorazd »

Thank you very much!
They both work, second one is bit quicker though during opening, so I am gonna use that one.
Post Reply