Need help with Batch: if exist wt = open in wt, else in cmd

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
KozakMak
Senior Member
Senior Member
Posts: 480
Joined: 2021-05-24, 12:39 UTC
Location: UA

Need help with Batch: if exist wt = open in wt, else in cmd

Post by *KozakMak »

...suspecting that this requires nircmd.
I want to open the current path in console, but with a condition: if exist wt = open in wt, else in cmd
OS: Win10 | TC: latest x64
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: if exist wt = open in wt, else in cmd

Post by *Stefan2 »

It couldn't harm if you would be more explizit.


What means "wt" for you?
Windows Terminal?

What do you mean by "cmd" ?
The Windows command line interpreter CMD.exe?



 
KozakMak
Senior Member
Senior Member
Posts: 480
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: if exist wt = open in wt, else in cmd

Post by *KozakMak »

Stefan2 wrote: 2024-07-17, 14:31 UTC Windows Terminal?
exactly
Stefan2 wrote: 2024-07-17, 14:31 UTC The Windows command line interpreter CMD.exe?
exactly
OS: Win10 | TC: latest x64
User avatar
Dalai
Power Member
Power Member
Posts: 9949
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: if exist wt = open in wt, else in cmd

Post by *Dalai »

You mean something like this:

Code: Select all

@echo off

setlocal

set CMD=%SystemRoot%\system32\cmd.exe
set WT=%SystemRoot%\system32\wt.exe

if exist "%WT%" (
    call "%WT%" %*
) ELSE (
    call "%CMD%" %*
)

endlocal
Save as e.g. WT_CMD.cmd and place it in %SystemRoot%. Drag it onto the button bar to create a new button. That should be all (you might need to make the current working directory empty).

PS: No idea if wt.exe exists in system32 directory; change the path if necessary.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
jonathanpoulin
Member
Member
Posts: 131
Joined: 2020-12-19, 12:09 UTC
Location: Saint-Marc-des-Carrières, QC Canada
Contact:

Re: if exist wt = open in wt, else in cmd

Post by *jonathanpoulin »

2KozakMak

I don't know if this is relevant in your case, but it can worth it to check your Windows Terminal app settings. If its setting 'Default terminal application' is set to "Windows Terminal", then running cmd.exe will be opened in Windows Terminal app automatically for you. The same goes for powershell.exe and pwsh.exe.
Thanks,
Jonathan Poulin
Post Reply