Search code examples
pythonwindowslow-latency

Set Windows command-line terminal title in Python


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 gives each of these shell windows the same name:

<User>: C:\Windows\system32\cmd.exe - <script.py>

Is it possible to set this name to something else through a Python command?


Solution

  • This works for Python2.7 under Windows.

    >>> import ctypes
    >>> ctypes.windll.kernel32.SetConsoleTitleA("My New Title")