Echo the path in windows

echo (вывод на экран) echo

Отображает сообщения или включает или отключает функцию вывода команд. Displays messages or turns on or off the command echoing feature. При использовании без параметров echo отображает текущее значение эха. If used without parameters, echo displays the current echo setting.

Синтаксис Syntax

Параметры Parameters

Параметр Parameter Описание Description
[вкл. | Откл.] [on | off] Включает или выключает функцию вывода команд. Turns on or off the command echoing feature. Команда по умолчанию включена. Command echoing is on by default.
Задает текст, отображаемый на экране. Specifies the text to display on the screen.
/? /? Отображение справки в командной строке. Displays help at the command prompt.

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

echo Команда особенно полезна при отключенном эхо . The echo command is particularly useful when echo is turned off. Чтобы отобразить сообщение, которое содержит несколько строк без отображения команд, можно включить несколько echo команд после команды echo off в пакетной программе. To display a message that is several lines long without displaying any commands, you can include several echo commands after the echo off command in your batch program.

После выключения эхо Командная строка не отображается в окне командной строки. After echo is turned off, the command prompt doesn’t appear in the Command Prompt window. Чтобы отобразить командную строку, введите команду echo on. To display the command prompt, type echo on.

Если используется в пакетном файле, Включение и вывод не влияют на параметр в командной строке. If used in a batch file, echo on and echo off don’t affect the setting at the command prompt.

Чтобы предотвратить вывод определенной команды в пакетном файле, вставьте @ знак перед командой. To prevent echoing a particular command in a batch file, insert an @ sign in front of the command. Чтобы предотвратить вывод всех команд в пакетном файле, включите команду echo off в начале файла. To prevent echoing all commands in a batch file, include the echo off command at the beginning of the file.

Чтобы отобразить символ канала ( | ) или перенаправления ( или > ) при использовании эха, используйте знак крышки ( ^ ) непосредственно перед символом канала или перенаправления. To display a pipe ( | ) or redirection character ( or > ) when you are using echo, use a caret ( ^ ) immediately before the pipe or redirection character. Например,, ^| ^> или ^ ). For example, ^| , ^> , or ^ ). Чтобы отобразить курсор, введите две крышки подряд ( ^^ ). To display a caret, type two carets in succession ( ^^ ).

Примеры Examples

Чтобы отобразить текущее значение echo , введите: To display the current echo setting, type:

Чтобы вывести на экран пустую строку, введите: To echo a blank line on the screen, type:

Не включайте пробел перед точкой. Don’t include a space before the period. В противном случае вместо пустой строки отображается точка. Otherwise, the period appears instead of a blank line.

Чтобы запретить вывод команд в командной строке, введите: To prevent echoing commands at the command prompt, type:

Когда эхо отключено, Командная строка не отображается в окне командной строки. When echo is turned off, the command prompt doesn’t appear in the Command Prompt window. Чтобы снова отобразить командную строку, введите команду echo on. To display the command prompt again, type echo on.

Чтобы предотвратить отображение на экране всех команд в пакетном файле (включая команду echo off ), в первой строке типа пакетного файла: To prevent all commands in a batch file (including the echo off command) from displaying on the screen, on the first line of the batch file type:

Команду echo можно использовать как часть оператора If . You can use the echo command as part of an if statement. Например, чтобы найти в текущем каталоге любой файл с расширением. rpt и вывести сообщение при обнаружении такого файла, введите: For example, to search the current directory for any file with the .rpt file name extension, and to echo a message if such a file is found, type:

Следующий пакетный файл выполняет поиск файлов с расширением txt в текущем каталоге и выводит сообщение с указанием результатов поиска: The following batch file searches the current directory for files with the .txt file name extension, and displays a message indicating the results of the search:

Если при выполнении пакетного файла не найдены TXT-файлы, отображается следующее сообщение: If no .txt files are found when the batch file is run, the following message displays:

Если TXT-файлы найдены при запуске пакетного файла, отображаются следующие выходные данные (в этом примере предполагается, что файлы File1.txt, File2.txt и File3.txt существуют): If .txt files are found when the batch file is run the following output displays (for this example, assume the files File1.txt, File2.txt, and File3.txt exist):

Windows CMD: PATH Variable – Add To PATH – Echo PATH

PATH is an environment variable that specifies a set of directories, separated with semicolons ( ; ), where executable programs are located.

In this note i am showing how to print the contents of Windows PATH environment variable from the Windows command prompt.

I am also showing how to add a directory to Windows PATH permanently or for the current session only.

Cool Tip: List environment variables in Windows! Read More →

Echo Windows PATH Variable

Print the contents of the Windows PATH variable from cmd :

The above commands return all directories in Windows PATH environment variable on a single line separated with semicolons ( ; ) that is not very readable.

To print each entry of Windows PATH variable on a new line, execute:

Cool Tip: Set environment variables in Windows! Read More →

Add To Windows PATH

Warning! This solution may be destructive as Windows truncates PATH to 1024 characters. Make a backup of PATH before any modifications.

Save the contents of the Windows PATH environment variable to C:\path-backup.txt file:

Set Windows PATH For The Current Session

Set Windows PATH variable for the current session:

Set Windows PATH Permanently

Run as Administrator: The setx command is only available starting from Windows 7 and requires elevated command prompt.

Permanently add a directory to the user PATH variable:

Permanently add a directory to the system PATH variable (for all users):

Info: To see the changes after running setx – open a new command prompt.

How this windows command works: echo %path:;=&echo.%

Searching for a solution to print pathes inside path variable in windows Command-Line i came to this solution. the answer is this command:

now i wonder how this works.

3 Answers 3

That’s an interesting solution that I’ve never seen before. Let me try to explain:

  1. To print the entire path, use echo %path% . This will print all directories on a single line separated with semicolons ( ; )
  2. To search / replace a string in a variable, use %path:a=b% which will replace all a characters with b
  3. echo. is used to print a newline
  4. & is used to separate commands, e.g. echo line1&echo line2 will print two lines
  5. In effect, semicolons in the path are replaced with a command to print a newline. Or maybe it is interpreted as ‘replace ; with nothing, and then, print a newline’. I can’t find any documentation on this, so it’s just my interpretation. Frankly, I didn’t even know that was possible, but there you go. UPDATE My interpretation of this step seems to be off, and is better explained by wizzwizz4.

Since & is a command separator, this is equivalent to:

Due to quirks of DOS Batch, echo. is identical to echo except when there’s nothing after it. If that’s the case, it simply prints nothing, instead of telling you whether ECHO is on or off. This will make the output:

Really, it should be echo.%path:;=&echo.% to account for the case where %PATH% starts with a ; , but this command is pretty clever anyway.

Getting into detailed detalias, really echo( should be used instead of echo. . This is because echo. can have problems when you’ve got a file called echo , and is slow because it has to check the disk ( %CD% and I think also all of %PATH% ) every time it runs. (I don’t have a copy of Windows so I can’t check it myself; is it just %CD% or anywhere in the %PATH% that the presence of the echo file will affect echo. , and what does it do?)

Echoing path variable in windows displaying twice

When i am trying to echo the system path variable it is showing the same thing twice.

My system path variable:

C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files\Common Files\MicrosoftShared\Windows Live;C:\Program Files (x86)\CommonFiles\MicrosoftShared\WindowsLive;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\DW WLAN Card;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\Windows Live\Shared;

And when i echo it on cmd echo %Path% it displays this

C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\WindowsLive;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\DW WLAN Card;C:\ProgramFiles\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files(x86)\WindowsLive\Shared;C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Program Files (x86)\PC ConnectivitySolution\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\DW WLAN Card;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\WindowsLive\Shared;F:\Java\jdk1.6.0_38\bin\

Can anybody help why is it displaying same values twice? And is there side effects of this?

How can I display the contents of an environment variable from the command prompt in Windows 7?

In Windows 7, when I start the Command prompt, is there any command to display the contents of an environment variable (such as the JAVA_HOME or PATH variables)?

I have tried with echo $PATH , echo PATH and $PATH but none of these work.

8 Answers 8

In Windows Command-Prompt the syntax is echo %PATH%

To get a list of all environment variables enter the command set

To send those variables to a text file enter the command set > filename.txt

To complement the previous answer, if you’re using Powershell echo %PATH% would not work. You need to use the following command instead: echo $Env:PATH

As an additional bit of information: While SET works with global or system variables, sometimes you want to write and read User variables, and this is done with the SETX command. SETX is included in the base installs of Windows beginning with Vista, but was also available in Windows XP by installing the Resource Pack.

One difference about SETX though is that you cannot read the variable out in the same command window you wrote it in. You have to write the SETX command in one Command or Powershell window, and then open a new window to read it using ECHO.

SETX can also write global or system variables.

To Set a user variable using SETX:

To set a global or system variable using SETX:

To read a user or global variable:

Remember, you must open a new Command or Powershell window to read this variable.

Читайте также:  Office 365 ��������� linux
Оцените статью