- PROMPT – изменение приглашения командной строки CMD Windows.
- Tips for changing directories in windows command line
- Change directory
- Change to a directory with spaces in the name
- Change drive and directory with single command
- Tips for changing directories in windows command prompt
- Use Pushd and Popd commands:
- How to Open Command Prompt
- Open Command Prompt to Execute Commands in Windows 10, 8, 7, Vista, & XP
- Open Command Prompt in Windows 10
- Open Command Prompt Through the Start Menu
- Open Command Prompt Using Power User Menu
- Open Command Prompt in Windows 8 or 8.1
- Open Command Prompt in Windows 7, Vista, or XP
- Other Ways to Open Command Prompt
- Elevated Command Prompts and Old Windows Versions
- Command Prompt: 11 basic commands you should know (cd, dir, mkdir, etc.)
- 1. How to change the directory (folder) in Command Prompt (CMD)
- 2. How to change the drive in Command Prompt (CMD)
- 3. How to view the contents of a directory in Command Prompt (CMD)
- 4. How to create a new directory with Command Prompt (CMD)
- 5. How to rename files and folders with Command Prompt (CMD)
PROMPT – изменение приглашения командной строки CMD Windows.
Формат командной строки:
текст — Новое приглашение командной строки.
Приглашение может включать обычные символы и следующие коды:
$A & (амперсанд)
$B | (вертикальная черта)
$C ( (левая круглая скобка)
$D Текущая дата
$E ESC (символ ASCII с кодом 27)
$F ) (правая круглая скобка)
$G > (знак «больше»)
$H BACKSPACE (удаление предыдущего символа)
$L $N Текущий диск
$P Текущие диск и каталог
$Q = (знак равенства)
$S (пробел)
$T Текущее время
$V Номер версии Windows
$_ Возврат каретки и перевод строки
$$ $ (символ доллара)
Когда расширенная обработка команд включена, команда PROMPT поддерживает следующие дополнительные символы форматирования:
$+ Отображение нужного числа знаков плюс (+) в зависимости от текущей глубины стека каталогов PUSHD, по одному знаку на каждый сохраненный путь.
$M Отображение полного имени удаленного диска, связанного с именем текущего диска, или пустой строки, если текущий диск не является сетевым.
При использовании PROMPT без параметров, выполняется установка текста приглашения в значение по умолчанию — $P$G — текущий диск и каталог и знак “Больше”.
prompt /? — отобразить подсказку по использованию команды.
В тексте приглашения можно использовать значение переменных окружения:
prompt %computername% $P$G — перед стандартным приглашением будет отображаться имя компьютера.
prompt $C%computername%$F $P$G — то же, что и в предыдущем примере, но имя компьютера будет заключено в скобки.
prompt $c%computername%$F$M$P$G — в скобках будет отображаться имя локального компьютера, путь сетевого ресурса в формате UNC, буква сетевого диска и путь, например:
(COMP0)\\SERVER\install i:\Piriform > — Локальный компьютер COMP0, сетевой ресурс \\SERVER\install , подключен как диск I: , текущий каталог — Piriform
prompt $D$_$T$_$P$G — текст приглашения представлен тремя строками, в первой отображается дата, во второй – время, в третьей – полный путь текущего каталога. Пример:
В примере, время представлено с точностью до сотых долей секунды — 17:50:58,62 . Для того, чтобы избавиться от них, и знака запятой в том числе, можно использовать три кода $H для удаления 3-х предшествующих им символа:
prompt $D$_$T$H$H$H$_$P$G — то же, что и в предыдущем примере, но время отображается без долей секунды — 17:50:58
Tips for changing directories in windows command line
In Windows command prompt, we can change the directory using the command cd . Both cd and chdir refer to the same command. Syntax of this command is explained below with some examples.
Change directory
When we launch command prompt, the default directory it opens with is C:\Documents and Settings\logind. This is in Windows XP. In Windows 7 command prompt opens up with the directory C:\Users\loginid. Now let’s say you want to traverse to the directory C:\Windows\System32. The command for this is given below.
Change to a directory with spaces in the name
In Windows, we can have spaces in the directory names. cd command can interpret the space correctly. So we do not need to enclose quotes around the directory name, as with most of other windows commands. An example is shown below.
Change drive and directory with single command
The basic cd command does not work if you are trying to change to a directory that is located on a different drive. Say you are in C:\users\cmdadmin\ directory and want to change to E:\docs directory. If you run ‘cd e:\docs‘ you won’t get any error but you would still be in the same folder. Only when you switch the drive by running the command ‘E:’ you will move to the folder e:\docs. You can avoid this by using /d option with cd command.
This command changes to the drive E: and also changes the directory to E:\docs.
Tips for changing directories in windows command prompt
If you frequently work with windows command line, then the below tips would help you in easily changing the directories in command line.
Use Pushd and Popd commands:
Pushd command is similar to cd but it also saves the current directory path. So if you want go back to the directory where you have come from, you can just use popd command. It will take you to the last directory you were working in.
Pushd can remember all the previous directories you traversed as long as you change the directory using pushd instead of cd command. Using popd you can go back to all the previously visited folders in the reverse order. See the below example.
How to Open Command Prompt
Open Command Prompt to Execute Commands in Windows 10, 8, 7, Vista, & XP
Some popular Command Prompt commands you might have heard of include ping, netstat, tracert, shutdown, and attrib, but there are many more. We have a complete list here.
While Command Prompt probably isn’t a tool most of you will use on a regular basis, it can really come in handy now and then, maybe to troubleshoot a specific Windows problem or to automate some kind of task.
How you open Command Prompt differs between Windows versions, so you’ll find steps below for Windows 10, Windows 8 or Windows 8.1, and Windows 7, Windows Vista, and Windows XP. See What Version of Windows Do I Have? if you’re not sure.
Open Command Prompt in Windows 10
Select the Start button.
Type cmd.
Select Command Prompt from the list.
Open Command Prompt Through the Start Menu
Another way to open Command Prompt in Windows 10 is to look in its Start menu folder:
Select the Start button.
Select the Windows System folder from the list.
Choose Command Prompt from the folder group.
Open Command Prompt Using Power User Menu
One more method in Windows 10 is through the Power User Menu. If you’re using a keyboard or mouse, choose Command Prompt from the menu that appears after pressing Win+X or right-clicking the Start button.
You might see Windows PowerShell options in the Power User Menu instead of Command Prompt. In more recent versions of Windows 10, Command Prompt has been replaced by PowerShell, but you can still access it from the Power User Menu by editing the taskbar settings.
Open Command Prompt in Windows 8 or 8.1
Select the Start button and then swipe up to show the Apps screen. You can accomplish the same thing with a mouse by selecting the down arrow icon at the bottom of the screen.
Prior to the Windows 8.1 update, the Apps screen can be accessed from the Start screen by swiping up from the bottom of the screen, or right-clicking anywhere, and then choosing All apps.
If you’re using a keyboard or mouse, a really quick way to open a Command Prompt window in Windows 8 is through the Power User Menu—just hold the WIN and X keys down together, or right-click the Start button, and choose Command Prompt.
Swipe or scroll to the right on the Apps screen to locate the Windows System section heading.
Select Command Prompt. You can now execute whatever command you needed to run.
See our List of Windows 8 Command Prompt Commands for a complete list of the commands available through Command Prompt in Windows 8, including short descriptions and links to more in-depth information if we have it.
Open Command Prompt in Windows 7, Vista, or XP
Open the Start menu from the bottom-left corner of the screen.
In Windows 7 and Windows Vista, it’s a bit faster to enter command in the search box at the bottom of the Start menu and then choose Command Prompt when it appears in the results.
Go to All Programs > Accessories.
Choose Command Prompt from the list of programs.
Here’s our List of Windows 7 Commands and List of Windows XP Commands if you need a command reference for any of those versions of Windows.
Other Ways to Open Command Prompt
Command Prompt in Windows XP through Windows 10 can also be opened with a command. This is especially helpful if you like using the Run dialog box or if Windows Explorer has crashed and the Start menu is inaccessible (and thus the directions above don’t work).
To do this, enter cmd into the command-line interface. This can be in the Run dialog box (WIN+R) or Task Manager’s File > Run new task menu.
Elevated Command Prompts and Old Windows Versions
In versions of Windows released before Windows XP, like Windows 98 and Windows 95, Command Prompt doesn’t exist. However, the older and very similar MS-DOS Prompt does. This program is located in the Start menu and can be opened with the command run command.
Some commands, like the sfc command that’s used to repair Windows files, require that Command Prompt be opened as an administrator before they can be executed. You’ll know if this is the case if you get a message like one of these after trying to execute the command:
- check that you have administrative rights
- . command can only be executed from an elevated command prompt
- you must be an administrator
See How to Open an Elevated Command Prompt for help starting Command Prompt as an administrator, a process that’s a bit more complicated than what’s outlined above.
Command Prompt: 11 basic commands you should know (cd, dir, mkdir, etc.)
Geeks and experts love the Command Prompt because of the advanced commands it can run. Fortunately, Command Prompt is not built only on advanced commands, but also on simple ones, designed to perform basic operations. In this article, we show you how to execute commands such as changing the current directory, switching to another drive, viewing the contents of a directory, creating and renaming folders, copying, deleting files and folders, and launching applications from the Command Prompt. We are also going to show you how to get help when using this app for Windows. Let’s get started:
NOTE: The information shared in this tutorial applies to Windows 10, Windows 8.1, and Windows 7. Note that, for simplicity, we are using screenshots taken only in Windows 10.
1. How to change the directory (folder) in Command Prompt (CMD)
The first command from the list is CD (Change Directory). This command enables you to change the current directory or, in other words, to navigate to another folder from your PC. For instance, the command CD takes you to the top of the directory tree. To see how it works, after you open the Command Prompt, type cd and press Enter on your keyboard. You should see how the CD command takes you to the top of the directory tree. In this case, to the “C:” drive.
Note that the Command Prompt is not case sensitive, meaning that you can type commands using capital letters, lowercase or any combination of them. The commands CD, cd or Cd, all work the same way.
Going back to the “CD” command, now you are working on the root of the “C:” drive. If you need to go to a specific folder from this drive run the command “CD Folder.” The subfolders must be separated by a backslash character: “.” For instance, when you need to access the System32 folder located in “C:\Windows,” type “cd windows\system32” as shown below, and then press Enter on your keyboard.
When you need to go one folder up, use the “cd..” command. Let’s assume that you want to go back to the Windows folder. Type “cd..” and press Enter on your keyboard.
The effect is that your current directory changes to “C:\Windows.”
2. How to change the drive in Command Prompt (CMD)
To access another drive, type the drive’s letter, followed by “:”. For instance, if you wanted to change the drive from “C:” to “D:”, you should type “d:” and then press Enter on your keyboard.
To change the drive and the directory at the same time, use the cd command, followed by the “/d” switch. The “/d” parameter is used to change the current drive to a specific folder from another disk volume.
For instance, if you are now on the “D:” drive and you want to go back to the Windows folder from the”C:” drive, you should type “cd /d C:\Windows” and press Enter on your keyboard, like in the following screenshot.
NOTE: By typing only the drive letter you automatically move to your most recent location on that drive. For instance, if you are on “D:” drive and type “cd c:\windows” nothing seems to happen. However, if you type “c:” then the working folder changes to “c:\windows,” assuming that it was the last folder you worked with on your “C:” drive.
3. How to view the contents of a directory in Command Prompt (CMD)
You can view the contents of a folder by using a command called DIR. To test it, we have created a folder named Digital_Citizen on the D: drive, with several files and subfolders. You can see them in the screenshot below.
The last time, our working folder was “C:\Windows.” To navigate to the folder mentioned above, we have to use the command “cd /d D:\Digital_Citizen.” To view the contents of the folder, type DIR, and press Enter. The list of the files and folders contained by it is displayed, together with some details about each of them (the size and the date and time when they were last modified).
4. How to create a new directory with Command Prompt (CMD)
You can make a new folder using the MKDIR (Make Directory) or the MD command. The syntax of these commands is “MKDIR Folder” or “MD Folder.”
Let’s say we need to create a new folder called Digital_Citizen_Life that is going to be placed in the “D:\Digital_Citizen” folder. To do that, we need to type “mkdir Digital_Citizen_Life” and then press Enter, as shown below.
To test if it worked, use the DIR command again. The newly created folder appears in the list.
NOTE: Do not forget that all these commands depend on the current location in the Command Prompt. For instance, if you are on the “C:” drive and type “MKDIR test,” the new folder is created in the root of the “C:” drive.
Another way to create a folder that does not involve being in the desired folder is to type the complete path of the new folder. For example, if you are working on the “D:” drive and you want to create a new folder in “C:,” called other_stuff, type “mkdir c:\other_stuff” and then press Enter.
When you need to create a folder with subfolders at the same time, you can use the “MKDIR FolderSubfolder” command. For instance, if we type “mkdir Digital_Citizen_Tests\Beta\Test1” three folders are created: Digital_Citizen_Tests, Beta and Test1, in a tree-like structure.
5. How to rename files and folders with Command Prompt (CMD)
To rename files and folders, you need to use the REN (Rename) command. To rename folders, type “ren Folder NewFolderName.” For example, if we wanted to rename the Digital_Citizen_Tests folder to Digital_Citizen_Final_Tests, we should run “ren Digital_Citizen_Tests Digital_Citizen_Final_Tests” and press Enter.
To rename a file, use the same command, like this: “ren filename.extension newname.extension”. For instance, to rename the Digital_Citizen_Picture1.bmp file to Image0.bmp, we have to run the command “ren Digital_Citizen_Image1.bmp Image0.bmp” command.
Read the second page of this tutorial if you want to learn how to copy files and folders, delete files and folders, start an application, and get help when using the Command Prompt.