1

Can I test the title of a Command Prompt window? I know that I can start a .bat file with a title:

start "idk_title" cmd /c ".\idk_name.bat"

But is there a way that I can test it? Something like this:

if title == "idk_title" echo wow the title says idk.
Thaltech
  • 43
  • 1
  • 10

2 Answers2

0

This powershell one liner wrapped in batch should do:

powershell -Nop -c "(([system.console]::title) -split ' - powershell')[0]"

To save it to a variable

:: Q:\Test\2018\12\28\SU_1388261.cmd
@Echo off
Title This is just a test text
for /f "usebackq delims=" %%A in (`
powershell -Nop -c "(([system.console]::title) -split ' - powershell')[0]"
`) do set "WindowTitle=%%A"
set WindowTitle

Sample output:

> Q:\Test\2018\12\28\SU_1388261.cmd
WindowTitle=This is just a test text
LotPings
  • 7,391
0

download CMDWIZ library,

right there; https://github.com/misol1/gotoxy/blob/master/cmdwiz.exe

and i say, it's working fine!

test;

 C:\Users\teo\Desktop | (Teoman)>title as da ds ad as da sda s

 C:\Users\teo\Desktop | (Teoman)>cmdwiz gettitle
 as da ds ad as da sda s - cmdwiz  gettitle

for more info about (gettitle) command... write "cmdwiz gettitle /?" if you want to save your title as a value.