Opening Windows Terminal from the command line

1 Oktober 2019

I started using the new Windows Terminal application more and more. I also often start a PowerShell from another PowerShell. Using the old command line infrastructure this was as easy as Start-Process PowerShell.

But the new Windows Terminal is a Shop App, or a Universal App, so it behaves differently from a normal Win32 program.

In my PowerShell profiles I had long support to start modern Windows apps, this is using COM interop and ActivateApplication to function, so I could do something like:

Start-WindowsApp -id Microsoft.WindowsTerminal_8wekyb3d8bbwe!App

and create a alias like:

wterm

to start a new Windows Terminal session. This works but requires some overhead in the PowerShell profile.

Then I read somewhere that you can just use Win+R and type wt, this indeed works but it didn't explain how?

Trying wt.exe works, but there is no executable wt.exe anywhere in the Windows path. I used SysMon to figure out where this executable is and found it in:

 %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\wt.exe

this path is also listed in the $env:path, but as a user specific entry, this is why it works from anywhere.

The file is a zero byte file and actually just a ReparsePoint, or softlink pointing to the actual App.

 junction64.exe C:\Users\xxx\AppData\Local\Microsoft\WindowsApps\wt.exe

results in:

 C:\Users\xxx\AppData\Local\Microsoft\WindowsApps\wt.exe: UNKNOWN MICROSOFT REPARSE POINT

so this is not a normal symbolic link, and the tools I usually use to inspect it, don't work.

The AppManifest.xml file of the Terminal app has the following lines:

  <Extensions>
    <uap3:Extension Category="windows.appExecutionAlias" Executable="WindowsTerminal.exe" EntryPoint="Windows.FullTrustApplication">
      <uap3:AppExecutionAlias>
        <desktop:ExecutionAlias Alias="wt.exe" />
      </uap3:AppExecutionAlias>
    </uap3:Extension>
  </Extensions>

I don't know enough about modern apps to understand how this all works together, but I found it interesting enough to investigate this a little.

Tags: Tools | Windows

Pages in this section

Categories

ASP.Net | Community | Development | IIS | IT Pro | Security | SQL (Server) | Tools | Web | Work on the road | Windows