I\'m running several instances of a certain Python script on a Windows machine, each from a different directory and using a separate shell windows. Unfortunately Windows giv
It is now possible to change the window title from within any language via outputting a standard escape sequence to the console (stdout). Here's a working example from a batch file Change command prompt to only show current directory name however just printing ESC close-bracket 2 semicolon your-title-here BEL (control-G) will do it. Also an easily adapted PHP example:
function windowTitle($title)
{printf("\033]2;%s\007", $title);}
Due to not enough rep I cannot add a comment to the above post - so as a new post.
In Python 3 you can use:
import ctypes
ctypes.windll.kernel32.SetConsoleTitleW("My New Title")
I edited this answer: please remark, that it now uses SetConsoleTitleW, which is the Unicode version of the SetConsoleTitle function. This way you can use unicode and no longer have to encode the string/variable to a byte object. You can just replace the argument with the string variable.
Since you're only going to be running this on Windows (IOW, there's not a cross-platform way to do this):
Inside of your script, you can change the title of the console with the function
win32console.SetConsoleTitle("My Awesome App")
I am not aware of a way to change the cmd
window title from within the script.
However, you can set the title when launching the script if you use the start command.
This works for Python2.7 under Windows.
>>> import ctypes
>>> ctypes.windll.kernel32.SetConsoleTitleA("My New Title")
In place of XYZ, enter the window name you want to keep.
import os
os.system("title XYZ")