Not So Simple Change Window Title

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
platypus
Posts: 8
Joined: 29 Dec 2016 18:27

Not So Simple Change Window Title

#1 Post by platypus » 16 Jul 2018 04:00

Inside a command prompt (cmd.exe) or a batch file this simple line will change a window title:

Title Any Chosen Name

Here are couple of applets (no command support) that will change the title of any window:

https://www.murgee.com/window-title-changer/
https://sourceforge.net/projects/windowtitle/

After many Google searches, I can't find any commands that will change a batch file window title
from another script. In other words, external lines acting upon a desktop command window.

This script at Stack Overflow creates a program (executable) that will change the title of any window:

https://stackoverflow.com/questions/390 ... 9#39033389

I want to change the title of cmd.exe windows, not all windows. Are there specific command lines
that will do the job, or must I create this SetText.exe program?

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

Re: Not So Simple Change Window Title

#2 Post by aGerman » 16 Jul 2018 10:10

platypus wrote:
16 Jul 2018 04:00
I want to change the title of cmd.exe windows, not all windows. Are there specific command lines
that will do the job, or must I create this SetText.exe program?
There is no command to change the title of a foreign window. Maybe it can be done using an emedded Powershell call. But that depends on how you want to select the window. Possible ways are
- current window title (where all windows with the specified title are changed)
- process name (where all main windows running with a specifies process name are changed)
- process id (where you need to know the id beforehand, which is rather unlikely)
- window class name (not really helpful and rather the same as using the process name)

Steffen

platypus
Posts: 8
Joined: 29 Dec 2016 18:27

Re: Not So Simple Change Window Title

#3 Post by platypus » 17 Jul 2018 07:21

Thanks aGerman.

I've never used AutoHotKey, but this tiny script could easily run as a command line inside a larger script:

https://autohotkey.com/docs/commands/WinSetTitle.htm

I started to read some of the AutoHotKey features. Any script can be compiled into an EXE file which makes
it completely portable. Looks like I'll be creating that SetText.exe program or using AutoHotKey.

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

Re: Not So Simple Change Window Title

#4 Post by aGerman » 17 Jul 2018 07:40

platypus wrote:
17 Jul 2018 07:21
Looks like I'll be creating that SetText.exe program or using AutoHotKey.
Of course you can basically use any language that supports the Windows API functions. But that was actually not my point. It's still the question how a program or script shall find the right window. See my list above. Then pick up what meets your requrements and compare with what the Basic program or the AutoHotKey function does to find the window. If either of them already match then use it. If not you should get back with the criteria how to find the window and I might be able to write some lines of Powershell code that you can embed in Batch (even if Powershell is not my favorite and I only have little experiences).

Steffen

Post Reply