CMD.exe to Windows Terminal Porting: command line commands

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
stephjo
Posts: 12
Joined: 03 Feb 2014 02:39

CMD.exe to Windows Terminal Porting: command line commands

#1 Post by stephjo » 18 Feb 2022 19:41

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

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

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

#2 Post by Squashman » 18 Feb 2022 20:33

Windows terminal does not replace cmd.exe
https://devblogs.microsoft.com/commandl ... -2019-faq/

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

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

#3 Post by aGerman » 19 Feb 2022 05:00

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

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

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

#4 Post by Compo » 19 Feb 2022 06:18

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"

Post Reply