Windows cmd window title

title title

Создает заголовок для окна командной строки. Creates a title for the Command Prompt window.

Синтаксис Syntax

Параметры Parameters

Параметр Parameter Описание Description
Задает текст, отображаемый в качестве заголовка окна командной строки. Specifies the text to appear as the title of the Command Prompt window.
/? /? Отображение справки в командной строке. Displays help at the command prompt.

Комментарии Remarks

Чтобы создать заголовок окна для пакетных программ, включите команду Title в начало пакетной программы. To create window title for batch programs, include the title command at the beginning of a batch program.

После установки заголовка окна его можно сбросить только с помощью команды Title . After a window title is set, you can reset it only by using the title command.

Примеры Examples

Чтобы изменить заголовок окна командной строки для обновления файлов во время выполнения пакетным файлом команды копирования , а затем для возвращения заголовка в командную строку, введите следующий скрипт: To change the Command Prompt window title to Updating Files while the batch file executes the copy command, and then to return the title back to Command Prompt, type the following script:

Show a “title” in the cmd.exe title-bar from a batch file?

According to the Microsoft Documentation, this is the syntax of the Start command:

So I created a batch file «test.bat» with this content:

. to supposedly have the cmd.exe console window showing the title «My test» in the title-bar.

However, when executing this .BAT file, the title «My test» is not displayed in the title bar of the console window:

So I tried this command in the .BAT file:

However, when executing this .BAT file, the whole command line was displayed in the title-bar of the console window:

. and notepad was not started.

So how can I display only the «title» in the title-bar of the console window and have the command executed?

OS: Windows 7 x64 SP1

1 Answer 1

The title command changes inside the window, just put title command in the actual file, or if you want some kind of launcher (I don’t know why you would want this) then have a bat using call to call the other bat (The one that would have the title command inside it)

EDIT: I found the answer, if you’re starting a program (with the command start «foo\bar\some spaces\path\yourbat.bat ) then the start command automatically interperets foo\bar\some spaces\path\yourbat.bat to be the title, too, but if you call start «title» «foo\bar\some spaces\path\yourbat.bat» then it will run your file AND interpret the first quotation marks to be the title, and the second the path

Not the answer you’re looking for? Browse other questions tagged batch-file cmd or ask your own question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Changing CMD’s Window Title

May 2, 2006

Changing CMD’s Window Title

When running command line tools, applications or batch files it is often necessary to watch the resultant command window. E.g. to detect their completion you can have the script wait until the command window has closed. The trouble with this is that when you run batch files the title of the command window is always just “C:\WINDOWS\system32\cmd.exe”. So if your script starts more than one batch file, or you have other CMD windows open, how do you know which CMD window is which?

Well how about predefining the window title of the new CMD window? We can do this with the Windows start command. The start command starts a new CMD window and lets you give it any title you want and run a program/command at the same time. For more info type start /? at the command prompt. So we can use this in Macro Scheduler with the Run Program command:

This enables us to monitor this specific window to see when the batch file completes:

Now you might be wondering why we’d want to do the above when you can just make the script wait for the program or command run to finish by setting RP_WAIT to 1, like this:

Well, you may need to manipulate the window at some point during the process. Or you might want the script to detect if the batch file is taking too long to complete, like this:

Using the start command like this to set the CMD window’s title makes it much easier to distinguish between other command windows and ensure we manipulate the one belonging to our batch file.

Windows cmd window title

Starts a new instance of the command interpreter, Cmd.exe. If used without parameters, cmd displays the version and copyright information of the operating system.

Syntax

Parameters

Parameter Description
/c Carries out the command specified by string and then stops.
/k Carries out the command specified by string and continues.
/s Modifies the treatment of string after /c or /k.
/q Turns the echo off.
/d Disables execution of AutoRun commands.
/a Formats internal command output to a pipe or a file as American National Standards Institute (ANSI).
/u Formats internal command output to a pipe or a file as Unicode.
/t: < | > Sets the background (b) and foreground (f) colors.
/e:on Enables command extensions.
/e:off Disables commands extensions.
/f:on Enables file and directory name completion.
/f:off Disables file and directory name completion.
/v:on Enables delayed environment variable expansion.
/v:off Disables delayed environment variable expansion.
Specifies the command you want to carry out.
/? Displays help at the command prompt.

The following table lists valid hexadecimal digits that you can use as the values for and :

Value Color
0 Black
1 Blue
2 Green
3 Aqua
4 Red
5 Purple
6 Yellow
7 White
8 Gray
9 Light blue
a Light green
b Light aqua
c Light red
d Light purple
e Light yellow
f Bright white

Remarks

To use multiple commands for , separate them by the command separator && and enclose them in quotation marks. For example:

If you specify /c or /k, cmd processes, the remainder of string, and the quotation marks are preserved only if all of the following conditions are met:

You don’t also use /s.

You use exactly one set of quotation marks.

You don’t use any special characters within the quotation marks (for example: & ( ) @ ^ | ).

You use one or more white-space characters within the quotation marks.

The string within quotation marks is the name of an executable file.

If the previous conditions aren’t met, string is processed by examining the first character to verify whether it is an opening quotation mark. If the first character is an opening quotation mark, it is stripped along with the closing quotation mark. Any text following the closing quotation marks is preserved.

If you don’t specify /d in string, Cmd.exe looks for the following registry subkeys:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun\REG_SZ

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun\REG_EXPAND_SZ

If one or both registry subkeys are present, they’re executed before all other variables.

Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

You can disable command extensions for a particular process by using /e:off. You can enable or disable extensions for all cmd command-line options on a computer or user session by setting the following REG_DWORD values:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD

Set the REG_DWORD value to either 0Г—1 (enabled) or 0Г—0 (disabled) in the registry by using Regedit.exe. User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.

Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

When you enable command extensions, the following commands are affected:

assoc

call

chdir (cd)

color

del (erase)

endlocal

for

ftype

goto

if

mkdir (md)

popd

prompt

pushd

set

setlocal

shift

start (also includes changes to external command processes)

If you enable delayed environment variable expansion, you can use the exclamation point character to substitute the value of an environment variable at run time.

File and directory name completion is not enabled by default. You can enable or disable file name completion for a particular process of the cmd command with /f:<on | off>. You can enable or disable file and directory name completion for all processes of the cmd command on a computer or for a user logon session by setting the following REG_DWORD values:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD

To set the REG_DWORD value, run Regedit.exe and use the hexadecimal value of a control character for a particular function (for example, 0Г—9 is TAB and 0Г—08 is BACKSPACE). User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.

Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

If you enable file and directory name completion by using /f:on, use CTRL+D for directory name completion and CTRL+F for file name completion. To disable a particular completion character in the registry, use the value for white space [0Г—20] because it is not a valid control character.

Pressing CTRL+D or CTRL+F, processes the file and directory name completion. These key combination functions append a wildcard character to string (if one is not present), builds a list of paths that match, and then displays the first matching path.

If none of the paths match, the file and directory name completion function beeps and does not change the display. To move through the list of matching paths, press CTRL+D or CTRL+F repeatedly. To move through the list backwards, press the SHIFT key and CTRL+D or CTRL+F simultaneously. To discard the saved list of matching paths and generate a new list, edit string and press CTRL+D or CTRL+F. If you switch between CTRL+D and CTRL+F, the saved list of matching paths is discarded and a new list is generated. The only difference between the key combinations CTRL+D and CTRL+F is that CTRL+D only matches directory names and CTRL+F matches both file and directory names. If you use file and directory name completion on any of the built-in directory commands (that is, CD, MD, or RD), directory completion is assumed.

File and directory name completion correctly processes file names that contain white space or special characters if you place quotation marks around the matching path.

You must use quotation marks around the following special characters: & [ ] | < >^ = ; ! ‘ + , `

If the information that you supply contains spaces, you must use quotation marks around the text (for example, «Computer Name»).

If you process file and directory name completion from within string, any part of the path to the right of the cursor is discarded (at the point in string where the completion was processed).

start

Starts a separate Command Prompt window to run a specified program or command.

Syntax

Parameters

Parameter Description
Specifies the title to display in the Command Prompt window title bar.
/d

Specifies the startup directory. /i Passes the Cmd.exe startup environment to the new Command Prompt window. If /i is not specified, the current environment is used. Specifies to minimize (/min) or maximize (/max) the new Command Prompt window. Starts 16-bit programs in a separate memory space (/separate) or shared memory space (/shared). These options are not supported on 64-bit platforms. Starts an application in the specified priority class. /affinity Applies the specified processor affinity mask (expressed as a hexadecimal number) to the new application. /wait Starts an application and waits for it to end. /elevate Runs application as administrator. /b Starts an application without opening a new Command Prompt window. CTRL+C handling is ignored unless the application enables CTRL+C processing. Use CTRL+BREAK to interrupt the application. [ [

. ]] Specifies the command or program to start.

Specifies parameters to pass to either the command or the program. /? Displays help at the command prompt.

Remarks

You can run non-executable files through their file association by typing the name of the file as a command.

If you run a command that contains the string CMD as the first token without an extension or path qualifier, CMD is replaced with the value of the COMSPEC variable. This prevents users from picking up cmd from the current directory.

If you run a 32-bit graphical user interface (GUI) application, cmd does not wait for the application to quit before returning to the command prompt. This behavior does not occur if you run the application from a command script.

If you run a command that uses a first token that does not contain an extension, Cmd.exe uses the value of the PATHEXT environment variable to determine which extensions to look for and in what order. The default value for the PATHEXT variable is:

Note that the syntax is the same as the PATH variable, with semicolons (;) separating each extension.

When searching for an executable file, if there is no match on any extension, start checks to see if the name matches a directory name. If it does, start opens Explorer.exe on that path.

Examples

To start the Myapp program at the command prompt and retain use of the current Command Prompt window, type:

To view the start command-line help topic in a separate maximized Command Prompt window, type:

Читайте также:  Как убрать область предварительного просмотра windows 10
Оцените статью