Page 1 of 1

CMD.exe to Windows Terminal Porting: command line commands

Posted: 18 Feb 2022 19:41
by stephjo
I recently switched to Windows 11 and I'm trying to use Windows Terminal (wt.exe) more instead of cmd.exe.

In Windows 10 and Windows 7, I used to have many batch files that would launch cmd.exe and issue commands using the /c option. Like this:

cmd.exe /c mkdir "c:\Users\mike\Desktop\newfold" & start "" "c:\Users\mike\Desktop\newfold"

Now, how can I do this with Windows Terminal? Anything like

wt.exe --c mkdir "c:\Users\mike\Desktop\newfold" & start "" "c:\Users\mike\Desktop\newfold"


Thank you,
-Stephanie

Re: CMD.exe to Windows Terminal Porting: command line commands

Posted: 18 Feb 2022 20:33
by Squashman
Windows terminal does not replace cmd.exe
https://devblogs.microsoft.com/commandl ... -2019-faq/

Re: CMD.exe to Windows Terminal Porting: command line commands

Posted: 19 Feb 2022 05:00
by aGerman
Don't confuse shell applications (like CMD or PowerShell) with terminal applications (like conhost.exe or wt.exe). It's critical to understand the difference. First ingest "CMD.EXE DOES NOT HAVE A WINDOW!", then read how this goes together with the fact that you are used to seeing a window as soon as you run it:
https://github.com/microsoft/terminal/b ... s-terminal
However, you can make Windows Terminal the default terminal application used by programs with a command line interface. That means, shell applications and shell scripts will then automatically run in the Windows Terminal instead of the Console Host.

Steffen

Re: CMD.exe to Windows Terminal Porting: command line commands

Posted: 19 Feb 2022 06:18
by Compo
stephjo wrote:
18 Feb 2022 19:41
In Windows 10 and Windows 7, I used to have many batch files that would launch cmd.exe and issue commands using the /c option. Like this:

cmd.exe /c mkdir "c:\Users\mike\Desktop\newfold" & start "" "c:\Users\mike\Desktop\newfold"
TBH, you should ideally look into the reason why you're doing that at all.

The batch files are already being run in a cmd.exe instance, so there is no reason why you should need to be invoking two commands in a new instance, or one command in a new instance like that.

Two commands in a new cmd.exe instance:

Code: Select all

%SystemRoot%\System32\cmd.exe /D /C "MD "%UserProfile%\Desktop\newfold" & Start "" "%UserProfile%\Desktop\newfold""
One command in a new cmd.exe instance:

Code: Select all

%SystemRoot%\System32\cmd.exe /D /C "MD "%UserProfile%\Desktop\newfold"" & Start "" "%UserProfile%\Desktop\newfold"
All you needed was this:

Code: Select all

MD "%UserProfile%\Desktop\newfold" & Start "" "%UserProfile%\Desktop\newfold"