Windows command prompt что это

Почти все современные программы и операционные системы рассчитаны на управление либо пальцем, либо мышкой. И это очень хорошо, если вы впервые открыли компьютер и ещё не знаете, что тут где. Все иконки выведены на экран, вы можете выбрать нужную команду, всё наглядно.

Но вы заметите, что опытные пользователи почти не касаются мышки: большую часть работы они делают с клавиатуры, и это у них получается гораздо быстрее. Это связано с тем, что нажимать на клавиши гораздо быстрее, особенно если уже есть мышечная память. 

У программ есть горячие клавиши, чтобы ускорять работу. А у операционной системы есть командная строка — это как горячие клавиши, только для всего компьютера.

Что может командная строка

Командная строка может всё, что может операционная система, и больше:

  • копировать и перемещать файлы, переименовывать их и создавать новые папки;
  • форматировать диски, подключать их и отключать;
  • запускать приложения и программы без интерфейса, давать им задания, получать результат;
  • менять параметры системы, работать с сетью;
  • до определённой степени — автоматизировать все эти дела; и многое другое.

Корректнее сказать так: командная строка умеет всё, что умеет операционная система, и даже больше.

Как вызвать командную строку

Командная строка встроена в каждый компьютер с Windows или MacOS. Программу, которая даёт доступ к командной строке, называют терминалом. 

Если у вас Windows, для вызова терминала нужно нажать комбинацию клавиш Win+R, в появившемся окне набрать cmd и нажать Enter. В MacOS — нажать Cmd+пробел, набрать terminal и тоже нажать Enter (это стандартная настройка, её можно изменить). 

Перед вами появится окно, куда можно вводить команды для компьютера.

Командная строка в Windows

Командная строка в Windows
Терминал в MacOS
Терминал в MacOS

Как работает

Смысл командной строки такой: вы пишете команды для компьютера, а он их выполняет. Все команды делятся на внутренние и внешние.

Внутренние команды — это те, которые уже встроены в операционную систему. С их помощью можно управлять компьютером в рамках базовых возможностей операционной системы.

Встроенная в Windows команда dir выводит список всех файлов и каталогов в текущей папке

Встроенная в Windows команда dir выводит список всех файлов и каталогов в текущей папке

Внешние команды — это все программы, которые пользователь ставит на компьютер сам. Часто бывает так, что при установке программа добавляет в систему нужные для себя вспомогательные программы — и они тоже становятся внешними командами. Например:

  1. вы поставили на компьютер программу VS Code, чтобы программировать на Python;
  2. после этого вы можете в командной строке набрать code, нажать клавишу ввода, и программа запустится;
  3. это значит, что сразу после установки этой программы у компьютера появилась новая команда — code.

Запускаем VS Code из командной строки

Запускаем VS Code из командной строки

Параметры команд

У многих команд есть параметры, которые дают дополнительные возможности. 

Например, мы уже видели, как команда dir без параметров просто выдаёт нам список всех файлов и каталогов в текущей папке. Но если мы добавим параметр /p, то она покажет на экране не весь список сразу, а по частям, чтобы всё помещалось на экран:

Зачем нужна командная строка

А та же команда dir c параметром /w уберёт все подробности и выведет содержимое папки в виде нескольких колонок:

Зачем нужна командная строка

Параметры вызова можно комбинировать и добавлять к ним свои запросы. Например, если нам нужно запустить VS Code так, чтобы он на старте открыл определённый файл ninja_sword.js, то можно написать так:

code d:/ninja_sword.js

открыть файл в VS code через командную строку

Примеры использования

С помощью командной строки можно решать много разных задач — от управления сервером до поиска файлов. Но вся мощь проявляется в случаях, когда нам нужно сделать много однотипных операций.

Представим такую ситуацию: мы скачали 30 подкастов, которые хотим послушать в дороге. Но после скачивания выяснилось, что громкость у всех записей очень тихая, и даже если выкрутить всё на максимум, её всё равно не хватает. Чтобы послушать подкасты, нам придётся:

  1. запустить аудиоредактор, 
  2. по очереди открыть в нём каждый файл, 
  3. вручную установить нужный уровень громкости,
  4. сохранить файл,
  5. открыть следующий и повторить всё то же самое,
  6. повторить ещё 28 раз

Очевидно, что это займёт много времени, и проще скачать другие подкасты, чем тратить столько сил на эти. Но, например, в MacOS мы можем открыть терминал и написать там две команды:

cd podcasts
for file in *; do wc -l $file; lame --scale 8 $file; done

Первая команда переходит в каталог с подкастами, а вторая:

  1. берёт все файлы в этой папке;
  2. получает их количество и название;
  3. в цикле запускает программу lame и указывает параметры для неё — поднять громкость в 8 раз у этого файла;
  4. повторяет цикл до тех пор, пока не обработаются все файлы.

В результате мы в той же папке получим те же файлы, но с увеличенной громкостью. По времени это будет гораздо быстрее, чем делать всё вручную. Но для этого нужно знать возможности командной строки, уметь с ней работать, знать команды и их параметры.

Вот что ещё можно делать через командную строку:

  • следить за нагрузкой на процессор;
  • настраивать автообновления программ;
  • делать резервные копии по расписанию;
  • генерировать тексты с помощью нейронки и результат сразу публиковать в телеграм-канале;
  • собирать почту со всех ящиков, фильтровать только важные письма, собирать их в одно, красиво его оформить и распечатать на принтере;
  • и что угодно ещё, если для этого есть команда или параметр вызова.

Зачем веб-разработчику командная строка

Затем, что большинство фреймворков ставятся и управляются из командной строки. Тот же Angular вообще позволяет через командную строку создавать шаблоны и заготовки приложений.

Если же вы занимаетесь веб-разработкой, то командная строка вам пригодится:

  • для установки всего серверного инструментария, например PHP, Apache и MySQL;
  • для работы с API и запросами;
  • для настройки серверного окружения и разграничения доступа;
  • для работы с репозиториями и для создания резервных копий проектов;
  • для тестирования сервера под нагрузкой;
  • для получения логов для анализа работы серверной части.

What to Know

  • Command Prompt can be found in the Start menu or Apps screen.
  • Alternatively, use the Run command cmd, or open from its original location: C:\Windows\system32\cmd.exe
  • To use, enter a valid Command Prompt command.

Command Prompt is a command line interpreter application available in most Windows operating systems. It’s used to execute entered commands. Most of those commands automate tasks via scripts and batch files, perform advanced administrative functions, and troubleshoot or solve certain kinds of Windows issues.

What Is Windows Command Prompt?

Command Prompt is officially called Windows Command Processor, but it’s also sometimes referred to as ​the command shell or cmd prompt, or even by its filename, cmd.exe.

Command Prompt is sometimes incorrectly referred to as «the DOS prompt» or as MS-DOS. Command Prompt is a Windows program that emulates many of the command line abilities available in MS-DOS, but it’s not MS-DOS.

Cmd is also an abbreviation for many other technology terms like centralized message distribution, color monitor display, and common management database, but none of them have anything to do with Command Prompt.

How to Access Command Prompt

There are several ways to open Command Prompt, but the «normal» method is via the Command Prompt shortcut located in the Start menu or on the Apps screen, depending on your version of Windows.

Opening Command Prompt in Windows 11.

The shortcut is faster for most people, but another way to access Command Prompt is via the cmd Run command. You can also open cmd.exe from its original location:

C:\Windows\system32\cmd.exe

Yet another method for opening Command Prompt in some versions of Windows is through the Power User Menu. However, you might see PowerShell there instead of Command Prompt depending on how your computer is set up. You can switch between Command Prompt and PowerShell from the Win+X menu.

How to Use Command Prompt

To use Command Prompt, you enter a valid Command Prompt command along with any optional parameters. Command Prompt then executes the command as entered and performs the task or function it’s designed to perform in Windows.

For example, executing the following Command Prompt command in your Downloads folder would remove all MP3s from that folder:

del *.mp3

Commands must be entered into Command Prompt exactly. The wrong syntax or a misspelling could cause the command to fail or worse; it could execute the wrong command or the right command in the wrong way. A comfort level with reading command syntax is recommended.

For example, executing the dir command will show a list of files and folders that exist at any specific location on the computer, but it doesn’t actually do anything. However, change just a couple letters and it turns into the del command, which is how you delete files from Command Prompt!

Syntax is so important that with some commands, especially the delete command, adding even a single space can mean deleting entirely different data.

Here’s an example where the space in the command breaks the line into two sections, essentially creating two commands where the files in the root folder (files) are deleted instead of the files in the subfolder (music):

del C:\files\ music

The proper way to execute that command so as to remove files from the music folder instead is to remove the space so that the whole command is strung together correctly.

Don’t let this scare you away from using Command Prompt commands, but definitely let it make you cautious.

Command Prompt Commands

A large number of commands exist in Command Prompt, but command availability varies across Microsoft Operating Systems.

Command Prompts for Windows Operating Systems:

  • Windows 8 Commands
  • Windows 7 Commands
  • Windows XP Commands
  • All Windows Command Prompt Commands

There are lots and lots of commands you can use in Command Prompt, but not all of them are used as often as others.

Here are some of the more commonly used Command Prompt commands that are utilized in a variety of circumstances: chkdsk, copy, ftp, del, format, ping, attrib, net, dir, help, and shutdown.

21 Best Command Prompt Tricks

Command Prompt Availability

Command Prompt is available on every Windows NT-based operating system which includes Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, and Windows 2000, as well as Windows Server 2012, 2008, and 2003.

Windows PowerShell, an advanced command line interpreter available in recent Windows versions, supplements the command executing abilities available in Command Prompt. Windows PowerShell may eventually replace the Command Prompt in a future version of Windows.

Windows Terminal is another Microsoft-approved way of using Command Prompt and PowerShell within the same tool. In fact, Terminal has replaced Command Prompt in Windows 11.

FAQ

  • How do I use a command prompt in macOS?

    The Terminal app is similar to the Command Prompt in Windows. To open it, go to Applications > Utilities > Terminal.

  • How do I change the directory in Command Prompt?

    To change directories, enter cd followed by a space. Then drag the folder or type the name of the folder into the command prompt.

Thanks for letting us know!

Get the Latest Tech News Delivered Every Day

Subscribe

Windows Prompt Command 2023 Blog

Today, most users ignore the Windows Command Prompt, as we can perform just about anything using the graphical interface. It’s easier, right? Well, why does Windows keep its prompt, then?

Although it’s almost 50 years old, it is not outdated. On the contrary, it’s very popular, and many find it incredibly useful. It has stood the test of time, so its existence is a sufficient reason to get familiar with it. It is the best way to perform many tasks, even in the modern age. Moreover, it’s pretty easy to use.

So, let’s get right to it! We’ll explain the basics of the command prompt Window, teach you how to open the Windows prompt command line, and give you a cheat sheet of the most popular CMD commands and what they do in more detail.

    • What Is Windows Command Line?

      • History of CMD Commands
    • Why Would You Use The Command Prompt?
    • How To Open the Windows Command Line?
    • How To Use the Windows Command Line?
    • Windows Command Prompt Cheat Sheet

      • Basic Commands
      • Files & Folders Commands
      • Disk & Partition Commands
      • Network Commands
      • System Information & Configuration Commands
    • How To View Your Command Prompt Window History?
    • The Next Step: Windows PowerShell

      • Windows Command Prompt vs. Windows PowerShell

        • Command Prompt:
        • PowerShell:
    • Conclusion

What Is Windows Command Line?

A command prompt or prompt is a command-line interface (CLI), a text-based user interface (UI) that enables you to perform various tasks within an OS or a program. For instance, you can interact with your computer, manage files and directories, run programs, script, automate, or perform other basic and advanced tasks.

Some operating systems provide you with a CLI exclusively, while others might grant you both a CLI and a GUI.

The Command Prompt or cmd.exe is the default command-line interpreter in Microsoft Windows, OS/2, eComStation, ArcaOS, and ReactOS operating systems. More precisely, it executes the commands you input in the Windows OS, like Terminal on macOS and Shell on Unix-based systems.

Both CLIs and GUIs are shells, programs that enable you to give commands to the computer. However, a CLI differs from a GUI, as the Graphical User Interface allows you to interact with the system using graphical elements, such as icons or menus, instead of text.

History of CMD Commands

Text-based commands go back to the existence of the Windows PC. Users could operate early Windows operating systems exclusively through CLIs; they didn’t have the mouse cursor or similar GUI elements.

Question: When did the CMD commands become available?

Answer: The Windows Prompt became available in December 1987. Virtually, Microsoft hasn’t changed its design since then. Yet, we officially recognize them as CMD commands in Windows 10, 8, 7, Vista, and XP.

The commands in earlier versions, including Windows 98/95, were known as DOS commands. Up to the 2000s, Windows versions included the MS-DOS integration, and clients ran commands using the MS-DOS Prompt. Later, starting with Windows XP in 2001, it was renamed Command Prompt.

Why Would You Use The Command Prompt?

Many customers haven’t even touched the Windows Command Prompt because modern, streamlined operating systems remove the need for old-school text commands. And sure, it might feel inconvenient to perform some tasks, such as managing files and folders using the command line, especially if you are used to the GUI.

Still, the command line is incredibly handy for many tasks, such as checking your IP address. Moreover, while it works at a basic level, the CMD is, in reality, the more powerful alternative.

It translates dozens of clicks in the GUI into a single line, thus shortening the time it takes to execute a new task. Power users also prefer it because it grants them more control over their computers and establishes direct communication.

Using the command window, you can perform advanced tasks, such as creating shortcuts to pin to the taskbar, accessing vital information, managing security issues, or fixing faults in Windows. Moreover, you can access parts of the operating system that are unavailable through the graphical user interface.

Last but not least, some of these commands apply to Linux, macOS, and many other operating systems, not only the Windows environment. So, learning them once may also benefit you in the future, even if you switch to another OS.

How To Open the Windows Command Line?

You can open the Command Prompt in Windows in a few ways:

  • Start Menu > Type “command prompt” > Press Enter

A screenshot from Windows PC displaying how to open the command prompt from the start menu.

  • Start Menu > Type “cmd” > Press Enter

A screenshot from Windows PC displaying how to open the command window from the start menu.

  • Press Win + R > Type “cmd” > Press Enter

A screenshot displaying how to open ports from the Run command dialog box on a Windows.

  • Right-click the Start Menu > Choose Command Prompt

  • Press Win + X > Choose Command Prompt

The Command Prompt in the Start Menu might also appear as Windows PowerShell or Windows Terminal, depending on your Windows settings. Both are more powerful yet compatible with CMD commands.

A screenshot of the Start Menu on a Windows, displaying the PowerShell option and clipboard-related topics.

Yet, remember that some commands require administrator access. To open a command prompt and perform some of the commands, make sure to choose the Admin option from the menu. For the other ways to open the CMD, hold Ctrl + Shift to get admin permission when you launch.

How To Use the Windows Command Line?

As soon as you open the command prompt, you’ll immediately learn a lot.

The first line shows you your Windows version. In my case, that’s 10.0.19045.2486. Also, pay attention to the third line, i.e., C:\Users\[Username]>. It refers to the Windows user and tells you where your commands will take place if CMD relies on location. Some CMD commands, however, are general. So, your location won’t matter.

A screenshot as an example of the command window.

Question: How many commands are there in CMD?

Answer: While the exact number of commands differs according to your Windows version, you can use approximately 100 commands.

The commands are not case-sensitive. Yet, as you are issuing them directly, try to type in the command correctly. Otherwise, the system won’t be able to understand you. But worry not; you cannot do much harm with a typo. If Windows doesn’t recognize the command, you’ll get a message saying: ‘[Command]’ is not recognized as an internal or external command, operable program, or batch file.

An example of a typo and the error message in an open command prompt.

However, typing the wrong command sure does some damage. If Windows recognizes the command, it will execute it immediately. So, it would be best to take your time and double-check everything. Moreover, avoid using the admin Command Prompt unless necessary.

Windows Command Prompt Cheat Sheet

Finally, we come to the most used commands in Windows OS. You can keep the list open on your desktop or print it; either way, keep it near to make the most out of CMD without feeling overwhelmed.

Basic Commands

Even if you have never used the command prompt window, some of its commands are welcoming to beginners.

Here’s a quick summary to help you start with the basics and build your knowledge:

  • Any command/?: Gives you information about the specific command and what it does

  • ARROW DOWN: Enables you to move forward in history toward the most recent command

  • ARROW UP: Enables you to step through the last called commands from the most recent one

  • call: Tells batch programs from one another

  • cd (change directory): Displays the name of or changes the current directory

  • chkdsk: Scans a disk for errors and delivers a status report

  • cls: Clears the contents of the Command Prompt

  • color: Applies the default console colors

  • Ctrl+A: Moves the caret to the beginning of the line

  • Ctrl+C: Cancels a command you are running

  • Ctrl+E: Moves the caret to the end of the line

  • Ctrl+K: Deletes all characters after the caret

  • Ctrl+L: Clears the screen

  • Ctrl+U: Deletes all characters before the caret

  • date: Displays or sets the date

  • del [file name]: Deletes the selected file

  • dir (directory): Lists all the files and subdirectories in the directory you are currently in

  • echo: Presents messages or turns command-echoing on/off.

  • exit: Quits the current echo setting or the CMD.EXE program

  • find: Searches for a text string in one or multiple files

  • help: Lists many common commands you can use

  • hostname: Prints the name of the current host

  • ipconfig: Provides a network overview for your current connection

  • mkdir [new folder name] (make directory): Creates a new folder

  • pause: Suspends processing of a batch program and displays the message

  • ping: Checks if your computer can reach a remote destination and how long it will take

  • prompt: Specifies a new command prompt

  • rmdir [folder name] (remove directory): Deletes an entire folder if it’s empty

  • sfc: Windows detects and fixes corrupt system files *you need admin access

  • TAB: Autocompletes what you have been writing

  • title: Sets the window title for the command prompt window

Once you get familiar with the basics, it’s time to take your skill to the next level. Let’s overview the most popular CMD commands for different tasks on Windows.

Files & Folders Commands

  • assoc: Displays or modifies file extension associations

  • attrib: Displays or changes file attributes

  • comp: Compares the contents of two files or sets of files

  • compact: Displays or alters the compression of files on NTFS partitions

  • expand: Expands one or more compressed files

  • fc: Compares two files or sets of files and displays their differences

  • find: Searches for a text string in one or multiple files

  • findstr: Searches for string patterns in files

  • md: Creates a directory

  • move: Moves and renames files and directories

  • openfiles: Lists or disconnects files and folders opened on a system *you need admin access

  • print: Prints a text file

  • ren (rename): Renames one or multiple files

  • replace: Replaces files

  • robocopy: Creates robust file copy for Windows

  • tree: Graphically displays the selected folder structure of a drive or path

  • type: Displays the contents of one or more text files

  • xcopy: Copies files and directory trees

Disk & Partition Commands

  • chkdsk: Checks a disk and displays a report

  • chkntfs: Displays or modifies the checking of the disk at boot time

  • convert: Converts a FAT volume to NFTS

  • format: Formats a disk for use with Windows

  • label: Creates, changes, or deletes the volume label of a disk

  • recover: Recovers readable information from a bad or defective disk

  • vol: Displays the disk volume label and serial number, if they exist

Network Commands

  • arp: Displays and modifies the IP to physical address translation tables used by ARP (Address Resolution Protocol)

  • bitsadmin: Creates, uploads or downloads jobs and monitors their progress

  • ftp: Transfers files to and from a computer running an FTP server service

  • ftype: Displays or modifies file types used in file extension associations

  • netsh: Configures, controls, and displays network components

  • netstat: Displays protocol statistics and current TCP/IP network connections

  • route: Manipulates network routing tables

  • systeminfo: Displays OS configuration information for a local or remote machine, including service pack levels

System Information & Configuration Commands

  • driverquery: Enables you to display a list of installed device drivers *you need admin access

  • powercfg: Enables you to control power settings on a local system

  • shutdown: Turns off computer

  • time: Displays or sets the system time

  • ver: Displays the Windows version

If you want to run multiple commands, combining them instead of waiting for them to complete one after another will save you a lot of time. To combine commands, separate them with a semicolon (;) on the same line.

Moreover, you can use the ‘only if’ option. You can link the command to its predecessor. If the command follows ‘&&,’ it will complete only if the previous command is completed successfully as well. On the contrary, if the command follows ‘||,’ it will complete only if the previous command has failed.

And if this is not enough and you want to take your knowledge on related topics to the next level, visit the official Microsoft page for a list of all commands with detailed explanations in alphabetical order.

How To View Your Command Prompt Window History?

One of the main disadvantages of the Command Prompt is that it only records data from the active session. So, if you have performed commands and rebooted your computer, in theory, you will be unable to review what you have done.

Fortunately, there are a few hacks, and we’ve decided to include them as extras in our Windows command prompt cheat sheet.

First, you can use the keyboard shortcut:

  • Open a command prompt

  • Run commands

  • Press the F7 key

  • Check the list of recent commands

  • Press the one you want to execute again

  • Hit enter

Second, you can search the command history:

  • Open a command prompt

  • Execute commands

  • Press the F7 key

  • Check the list of recent orders

  • Press the F8 key

  • Type what you remember from the line

  • Press the F8 key again

  • If you don’t like the result, press the F8 key again to view another entry

Next, you can use the doskey:

  • Launch the Prompt

  • Type doskey/history

It will enable you to recall previously typed commands, edit command lines, or even create macros.

Last but not least, you can export your prompt history to file:

  • Run the CMD as an Administrator

  • Type doskey /h > c:\cmd_history.txt

  • Change the c:\cmd_history.txt to represent the file path and name you want to export your current history to

The Next Step: Windows PowerShell

PowerShell is an alternative to the Windows Command Prompt. It consists of a command-line shell, a scripting language, and a configuration management framework and is compatible with Windows, Linux, and macOS.

Question: When was PowerShell released?

Answer: Microsoft released PowerShell 1.0 in November 2006 for Windows XP SP2, Windows Server 2003 SP1, and Windows Vista.

Initially, the company released PowerShell as an optional component with many useful commands, known as cmdlets. Their goal was to integrate the cmdlets better with their offerings, for them to batch files and VB scripts.

But, just recently, the company also announced that PowerShell is replacing the CMD.EXE. Fortunately, you can still use the Command Prompt if you prefer.

Windows Command Prompt vs. Windows PowerShell

PowerShell is the more advanced and the latest version of the Command Prompt. It enables you to execute more or less the same commands as CMD. At the same time, it facilitates carrying out administrative tasks.

Let’s review a few of their differences briefly so that you can understand both applications better.

Command Prompt:

  • Works with Batch commands exclusively

  • You cannot create aliases for commands

  • You cannot pass the output from a command on to other commands

  • Output comes out in the form of text

  • No separate ISE

  • Requires an external plugin for WMI interaction

  • It doesn’t support Linux OS

  • You can only run console-type programs

  • It cannot connect to Microsoft cloud products

PowerShell:

  • Works with Batch commands and PowerShell cmdlets

  • You can create aliases for cmdlets or scripts

  • You can pass the output from a cmdlet on to other cmdlets

  • Output comes out in the form of an object

  • Has a separate ISE

  • It can integrate directly with WMI

  • Fully supports Linux OS

  • You can run all types of programs

  • It can connect to Microsoft cloud products

So, which one should you learn? It depends on your needs. PowerShell is a relatively new product. It is easy to interpret, provides more compatibility and options, and you can expect a lot of advancements promptly. On the other hand, you can perform most of the tasks using the old-school and all-timer CMD.

Conclusion

While an unpopular opinion, the CMD is, in fact, much more powerful than a GUI. Better yet, it’s not only intended for experienced or advanced users. It’s quite the contrary. The Windows prompt is equally suitable for newcomers, as it’s time-efficient and easy to use.

The bottom line is that learning about the Windows command prompt is worth it. And our Windows command prompt cheat sheet is the perfect place to start and get the most out of your Windows experience!

From Wikipedia, the free encyclopedia

For other uses, see CMD.

«Command Prompt» redirects here. For the concept, see Command prompt.

Command Prompt (cmd.exe)

Other names Windows Command Processor
Developer(s) Microsoft, IBM, ReactOS contributors
Initial release December 1987; 35 years ago
Operating system
  • Windows NT family
  • Windows CE family
  • OS/2
  • eComStation
  • ArcaOS
  • ReactOS
Platform IA-32, x86-64, ARM (and historically DEC Alpha, MIPS, PowerPC, and Itanium)
Predecessor COMMAND.COM
Type Command-line interpreter

Command Prompt, also known as cmd.exe or cmd, is the default command-line interpreter for the OS/2,[1] eComStation, ArcaOS, Microsoft Windows (Windows NT family and Windows CE family), and ReactOS[2] operating systems. On Windows CE .NET 4.2,[3] Windows CE 5.0[4] and Windows Embedded CE 6.0[5] it is referred to as the Command Processor Shell. Its implementations differ between operating systems, but the behavior and basic set of commands are consistent. cmd.exe is the counterpart of COMMAND.COM in DOS and Windows 9x systems, and analogous to the Unix shells used on Unix-like systems. The initial version of cmd.exe for Windows NT was developed by Therese Stowell.[6] Windows CE 2.11 was the first embedded Windows release to support a console and a Windows CE version of cmd.exe.[7] The ReactOS implementation of cmd.exe is derived from FreeCOM, the FreeDOS command line interpreter.[2]

Operation[edit]

cmd.exe interacts with the user through a command-line interface. On Windows, this interface is implemented through the Win32 console. cmd.exe may take advantage of features available to native programs of its own platform. For example, on OS/2 and Windows, it can use real pipes in command pipelines, allowing both sides of the pipeline to run concurrently. As a result, it is possible to redirect the standard error stream. (COMMAND.COM uses temporary files, and runs the two sides serially, one after the other.)

Multiple commands can be processed in a single command line using the command separator &&.[8]

When using this separator in the Windows cmd.exe, each command must complete successfully for the following commands to execute. For example:

C:\>CommandA && CommandB && CommandC

In the above example, Command B will only execute if Command A completes successfully, and the execution of Command C depends on the successful completion of Command B. To process subsequent commands even if the previous command produces an error, the command separator & should be used.[9] For example:

C:\>CommandA & CommandB & CommandC

On Windows XP or later, the maximum length of the string that can be used at the command prompt is 8191 characters. On earlier versions, such as Windows 2000 or Windows NT 4.0, the maximum length of the string is 2047 characters. This limit includes the command line, individual environment variables that are inherited by other processes, and all environment variable expansions.[10]

Quotation marks are required for the following special characters:[8]

& < > [ ] { } ^ = ; ! ' + , ` ~ [white space]

Internal commands[edit]

OS/2[edit]

OS/2 Window (cmd.exe) on Microsoft OS/2 Version 1.3

The following is a list of the Microsoft OS/2 internal cmd.exe commands:[11]

  • break
  • chcp
  • cd
  • chdir
  • cls
  • copy
  • date
  • del
  • detach
  • dir
  • dpath
  • echo
  • erase
  • exit
  • for
  • goto
  • if
  • md
  • mkdir
  • path
  • pause
  • prompt
  • rd
  • rem
  • ren
  • rename
  • rmdir
  • set
  • shift
  • start
  • time
  • type
  • ver
  • verify
  • vol

Windows NT family[edit]

cmd.exe on Windows 11

The following list of internal commands is supported by cmd.exe on Windows NT and later:[12]

  • assoc
  • break
  • call
  • cd
  • chdir
  • cls
  • color
  • copy
  • date
  • del
  • dir
  • dpath
  • echo
  • endlocal
  • erase
  • exit
  • for
  • ftype
  • goto
  • if
  • keys
  • md
  • mkdir
  • mklink (introduced in Windows Vista)
  • move
  • path
  • pause
  • popd
  • prompt
  • pushd
  • rd
  • rem
  • ren
  • rename
  • rmdir
  • set
  • setlocal
  • shift
  • start
  • time
  • title
  • type
  • ver
  • verify
  • vol

Windows CE[edit]

Pocket CMD v 3.0 (cmd.exe) on Windows CE 3.0

The following list of commands is supported by cmd.exe on Windows CE .NET 4.2,[13] Windows CE 5.0[14] and Windows Embedded CE 6.0:[15]

  • attrib
  • call
  • cd
  • chdir
  • cls
  • copy
  • date
  • del
  • dir
  • echo
  • erase
  • exit
  • goto
  • help
  • if
  • md
  • mkdir
  • move
  • path
  • pause
  • prompt
  • pwd
  • rd
  • rem
  • ren
  • rename
  • rmdir
  • set
  • shift
  • start
  • time
  • title
  • type

In addition, the net command is available as an external command stored in \Windows\net.exe.

ReactOS[edit]

Command Prompt (cmd.exe) on ReactOS

The ReactOS implementation includes the following internal commands:[2]

  • ?
  • alias
  • assoc
  • beep
  • call
  • cd
  • chdir
  • choice
  • cls
  • color
  • copy
  • ctty
  • date
  • del
  • delete
  • delay
  • dir
  • dirs
  • echo
  • echos
  • echoerr
  • echoserr
  • endlocal
  • erase
  • exit
  • for
  • free
  • goto
  • history
  • if
  • memory
  • md
  • mkdir
  • mklink
  • move
  • path
  • pause
  • popd
  • prompt
  • pushd
  • rd
  • rmdir
  • rem
  • ren
  • rename
  • replace
  • screen
  • set
  • setlocal
  • shift
  • start
  • time
  • timer
  • title
  • type
  • ver
  • verify
  • vol

Comparison with COMMAND.COM[edit]

On Windows, cmd.exe is mostly compatible with COMMAND.COM but provides the following extensions over it:

  • More detailed error messages than the blanket «Bad command or file name» (in the case of malformed commands) of COMMAND.COM. In OS/2, errors are reported in the chosen language of the system, their text being taken from the system message files. The HELP command can then be issued with the error message number to obtain further information.
  • Supports using of arrow keys to scroll through command history. (Under DOS this function was only available under DR DOS (through HISTORY) and later via an external component called DOSKEY.)
  • Adds rotating command-line completion for file and folder paths, where the user can cycle through results for the prefix using the Tab ↹, and ⇧ Shift+Tab ↹ for reverse direction.
  • Treats the caret character (^) as the escape character; the character following it is to be taken literally. There are special characters in cmd.exe and COMMAND.COM (e.g. «<«, «>» and «|») that are meant to alter the behavior of the command line processor. The caret character forces the command line processor to interpret them literally.
  • Supports delayed variable expansion with SETLOCAL EnableDelayedExpansion, allowing values of variables to be calculated at runtime instead of during parsing of script before execution (Windows 2000 and later), fixing DOS idioms that made using control structures hard and complex.[16] The extensions can be disabled, providing a stricter compatibility mode.

Internal commands have also been improved:

  • The DELTREE command was merged into the RD command, as part of its /S switch.
  • SetLocal and EndLocal commands limit the scope of changes to the environment. Changes made to the command line environment after SetLocal commands are local to the batch file. EndLocal command restores the previous settings.[17]
  • The Call command allows subroutines within batch file. The Call command in COMMAND.COM only supports calling external batch files.
  • File name parser extensions to the Set command are comparable with C shell.[further explanation needed]
  • The Set command can perform expression evaluation.
  • An expansion of the For command supports parsing files and arbitrary sets in addition to file names.
  • The new PushD and PopD commands provide access past navigated paths similar to «forward» and «back» buttons in a web browser or File Explorer.
  • The conditional IF command can perform case-insensitive comparisons and numeric equality and inequality comparisons in addition to case-sensitive string comparisons. (This was available in DR-DOS, but not in PC DOS or MS-DOS.)

See also[edit]

  • Comparison of command shells
  • List of DOS commands
  • COMMAND.COM
  • PowerShell
  • Windows Terminal

References[edit]

  1. ^ «Notes on using the default OS/2 command processor (CMD.EXE)». www.tavi.co.uk.
  2. ^ a b c «reactos/reactos». GitHub. 4 December 2021.
  3. ^ «Command Processor Shell (Windows CE .NET 4.2)». docs.microsoft.com.
  4. ^ «Command Processor Shell (Windows CE 5.0)». docs.microsoft.com.
  5. ^ «Command Processor Shell (Windows Embedded CE 6.0)». docs.microsoft.com.
  6. ^ Zachary, G. Pascal (1994). Showstopper! The Breakneck Race to Create Windows NT and the Next Generation at Microsoft. The Free Press. ISBN 0-02-935671-7.
  7. ^ Douglas McConnaughey Boling (2001). Programming Microsoft Windows CE (2nd ed.). Microsoft Press. ISBN 978-0735614437.
  8. ^ a b «cmd». docs.microsoft.com.
  9. ^ «Command Redirection, Pipes — Windows CMD — SS64.com». ss64.com. Retrieved 2021-09-23.
  10. ^ Command prompt (Cmd.exe) command-line string limitation
  11. ^ Microsoft Operating System/2 User’s Reference (PDF). Microsoft. 1987.
  12. ^ Hill, Tim (1998). Windows NT Shell Scripting. Macmillan Technical Publishing. ISBN 978-1578700479.
  13. ^ «Command Processor Commands (Windows CE .NET 4.2)». docs.microsoft.com.
  14. ^ «Command Processor Commands (Windows CE 5.0)». docs.microsoft.com.
  15. ^ «Command Processor Commands (Windows Embedded CE 6.0)». docs.microsoft.com.
  16. ^ «Windows 2000 delayed environment variable expansion». Windows IT Pro. Archived from the original on 2015-07-13. Retrieved 2015-07-13.
  17. ^ «Setlocal». TechNet. Microsoft. Retrieved 2015-01-13.

Further reading[edit]

  • David Moskowitz; David Kerr (1994). OS/2 2.11 Unleashed (2nd ed.). Sams Publishing. ISBN 978-0672304453.
  • Stanek, William R. (2008). Windows Command-Line Administrator’s Pocket Consultant (2nd ed.). Microsoft Press. ISBN 978-0735622623.

External links[edit]

  • «Command-line reference A-Z». Microsoft.
  • «Cmd». Microsoft Windows XP Product Documentation. Microsoft. Archived from the original on 2011-09-02. Retrieved 2006-05-24.
  • «Command Prompt: frequently asked questions». windows Help. Microsoft. Archived from the original on 2015-04-22. Retrieved 2015-04-20.
  • «An A–Z Index of the Windows CMD command line». SS64.com.
  • «Windows CMD.com – Hub of Windows Commands». windowscmd.com. Archived from the original on 2022-01-11. Retrieved 2022-01-04.

Everyone who uses Windows on a daily basis has definitely bumped into the command prompt every once in a while. It’s one of those things that you know exists, but most likely have no idea how to use or what it’s for. Most advanced users know a few basic commands, but very few know how to fully take advantage of the Windows Command Prompt.

That’s why it’s a damn good thing you are here. You are about to learn everything there is to know about the Command Prompt, also known as cmd or console. We will start off with the basics, like different ways to open it, as well as basic navigation and file modification. After that, we will move on to more complex commands and features.

No matter if you’ve never touched the command prompt before or you are an expert at it, you will definitely find tons of useful information in this guide.

If a video format is more your style, you can check out this guide on our YouTube channel. It won’t be as in-depth, but contains all the main commands and features you need to learn.


What is the Command Prompt?

Command Prompt or CMD is a command line interpreter, in which the user interacts with the the command prompt through its command-line interface. It can be used to interact with the Windows operating system through various built-in commands. It is not a cross-platform application, as it is native to Windows, unlike it’s big brother, PowerShell which works on many other operating systems.

The command prompt was most popular in its early days, as the user interfaces were a lot more limited back then. Navigating through the files on a computer was simple when using only the keyboard. Nowadays most people don’t know how to use cmd because there is often no real need for it.

Many of the basic functions in command prompt can be done easily with basic mouse operations and menus, so most end-users will never need to use CMD. However, even in the age of mouse dominated PC operations, there are tons of useful things you can only accomplish through the command prompt on Windows and that’s what we’re here to find out.

Let’s start off with the basics first, then move on to some more complicated examples and commands.


Quick Ways to Launch Command Prompt

The best thing about command prompt on windows besides its many uses; is how fast you can get it going. The easiest way to open it up is to just open up your start menu and look for the Command Prompt within it, but there are a few faster alternatives.

The easiest and probably fastest way to launch CMD on Windows operating systems is by pressing the Windows Key and typing in ‘cmd‘. You should then see the command prompt icon appear and then you can open it up by clicking on it. This is the way I tend to open it up, as I don’t use the command prompt more than a few times a week.

Opening Command Prompt Through Start Menu

If you find yourself using the command prompt on a daily basis, it might be a better idea to pin the command prompt to your taskbar. This way it’s just one click away at all times.

In order to pin command prompt to your taskbar, first you need to find it in the start menu with the method showcased above. Then all you need to do is right-click on the app icon and select the ‘Pin to taskbar‘ option. Now you should see the CMD icon on your Windows taskbar at all times.

Pin Command Prompt to Taskbar


Run Command Prompt as Administrator

Sometimes you need to let Windows know that you have enough permissions to access certain directories and files. This includes other users folders and sensitive files within folders like System32, which might cause issues when tampered with. Also if you are going to be running batch scripts or using advanced commands, you need elevated permissions.

The easiest way to run command prompt as administrator is by finding it in the start menu as shown above, then right-clicking it and selecting the ‘Run as administrator‘ option from the drop-down menu. However, there is an even easier way to accomplish this if you pinned the app to your taskbar.

If you wish to automatically run cmd as admin every time you open it, just follow these simple steps. First, right-click the icon in your taskbar and then right-click the ‘Command Prompt’ selection from that pop-up menu as well. Once you see the menu, you could just run it as administrator from there, but select the ‘Properties‘ tab instead.

Open Cmd Properties Windows 10

When you have opened up the ‘Properties‘ window, look for the tab labelled ‘Shortcut‘ and select it. Once you’re there, click on the ‘Advanced…‘ button to open up the advanced properties of the CMD shortcut. Finally, the last thing you need to do is tick the ‘Run as administrator’ checkbox. Now just click OK on both menus and you’re done.

Cmd Properties WindowCmd Properties Run As Administrator

After this step is done, every time you click on the command prompt icon in your taskbar, it will launch as admin automatically. This will save you a few clicks and you don’t ever have to remember to do it again. In order to make sure that you are running the cmd as an admin, you should see the text ‘Administrator: Command Prompt‘ at the top toolbar of the window.

Cmd Toolbar Admin Notification


Command Prompt vs Windows PowerShell

You might have already heard about PowerShell, but might not know what it is or how it differs from the normal command prompt. In a nutshell, PowerShell is a more complex and powerful alternative to cmd, a Command Prompt on steroids. You can do everything with PowerShell that you can do with cmd and much more.

The reason why most people have never used PowerShell, is because it hasn’t been integrated with Windows operating systems until Windows 7. Ever since then, it comes pre-installed and you can find it in the same manner as the cmd through your start menu. You can also pin it to the taskbar and run as admin the same way.

You can launch PowerShell just as you would CMD, but there is also a new quick method to do this in Windows 10. The best way to quickly open PowerShell on Windows by pressing the Windows key + X to open up a hidden menu. From that menu you can find ‘Windows PowerShell (Admin)‘ from which you can instantly open PowerShell as an administrator.

Open PowerShell as Admin

In the end it’s completely up to you if you wish to use the default Command Prompt or PowerShell, but here are some benefits of using PowerShell:

  • PowerShell uses the .NET framework allowing users to use actual programming libraries and allowing for the creation of custom commands.
  • It’s cross platform so you can use your newly learned skills on Windows, Linux and MacOS while the normal Command Prompt is only usable on Windows.
  • PowerShell uses a lot of easier-to-understand commands and tons of documentation about all commands through the Get-Help command.
  • It has a higher learning curve as there’s a lot more things to learn about, almost like learning a new language. This means there’s more potential as well.
  • Most end users will only ever need the CMD, which is why we will stick to it in this guide, but if you’re feeling up for it, we recommend you start with PowerShell as it will be more beneficial for you in the long run.

If you would like a guide similar to this one about Windows PowerShell, let us know in the YouTube video comments or through our About Us page.

You can find more information and documentation about the app on the official PowerShell Microsoft Documentation page.


Few Important Base Commands to Learn in CMD

To start your CMD journey, there are a few basic commands that are going to help you on your way.

As with all new software and applications, it’s great to have instructions or a user manual. Although this guide should have you covered, it’s nice to know how to find help within command prompt itself.

In order to find a neat list of all the basic commands within CMD, all you need to do is type in help and press enter.

The list above is a great refresher on the available commands, but they don’t explain much usage wise. That’s why there is a different documentation command which provides more in-depth information for each command.

In order to see the guide for a specific command, you can type help COMMAND or COMMAND /? both of which will show the same information.

Command Prompt Help Information

If you see ‘Press any key to continue…’ at the bottom, you can press any key to open up the rest of the info.

Now that you have a huge wall of text in your command prompt, you might be wondering how to get rid of it. Thankfully there’s a command for that instead of just scrolling down constantly.

In order to empty out the cmd of all text, you need to type in cls which stands for Clear Screen. It’s extremely useful once your prompt starts to get cluttered.

Another quick useful tip is that you can paste whatever text is on your clipboard by simply right-clicking anywhere on the command prompt window.

In order to copy whatever your command outputs, you can simply add | copy after the command. This will copy any results onto your clipboard.

It is good to note that all commands within the cmd are NOT case sensitive, so you can write in upper- or lower-case letters as you please. For example, help and HELP are the same command and work just fine. I prefer writing everything in lower case, as it seems faster.

Finally, if you don’t like to move your mouse to exit the command prompt, you can simply type exit in order to close down the cmd instantly.


System & Folder Navigation

Now we’re ready to get into the thick of things. These commands are the first thing you need to learn in order to navigate through your system within command prompt. They consist of changing folders and directories as well as switching between drives.


Change Directory (cd)

This is usually the first command you learn when starting out with cmd. When starting up the command prompt as administrator, you start out in the C:\WINDOWS\system32 folder.

In order to move up one level in the folder hierarchy, you need to type cd .. so if you execute this command twice, you will be in the root of your C:\ drive. In addition, to go directly to the root level, in this case the C drive base, you can simply type cd / with or without the white-space.

Command Prompt Change Directory

Notice that the whitespace after cd is not necessary for the command to work.

If you want to change the drive you are working in, all you need to do is type in the drive letter followed by a colon. For example, if you would like to change from C:\WINDOWDS\system32 to X:\ just type in X: and you’re done.

If you want to move to a specific folder within the current directory you can type in cd DIRECTORYNAME which is one of the most used commands. You can also press TAB while writing the folder name to auto-fill it. It will speed up your process and navigation a lot.

In order to move to specific path on the current drive, you can type the entire path after cd to jump there. For example if you’re located in C:\, you can type cd Windows/System32 to move up directly to the System32 folder.

If you want to jump to a different hierarchy on the same drive you need to start off with the drive letter. For example you can type in cd C:/Users/TechTipVault to move directly to that folder, no matter where you are currently.

Similarly if you want to jump to a path on a different drive, you need to add in cd /d and then the full path. For example if you want to move from C:/Users to X:/Users, you need to type in cd /d X:/Users and voilà.

Command Prompt Change Directory All Commands

Here are some examples of the commands listed above.

Finally, it’s good to note that it is good practice to surround any folder names with quotes if they contain white-space. It is not required in all cases, but it is good to get used to. For example, you should type a path like this: cd C:/"Program Files (x86)"/"Tech Tip Vault"/dot_com


List Files and Directories (dir)

When you’re navigating through your system with cmd, you often want to know what your options are in the active directory. Thankfully there is a very versatile command that allows you to see all the files, directories and sub-directories in the current folder.

In order to see basic information about every file and folder in the current directory, type dir in the command prompt.

If you want to view the contents of a folder you’re not currently in, you can also use dir for that. The catch is, you need to use back-slashes or quotes for the file-path as otherwise the path won’t be recognized. This is due to the additional parameters that can be used. For example, if you want to see the contents of the Users folder, you can either type dir C:\Users or dir "C:/Users" as both options work the same. It just really depends on if you hate typing back-slashes as much as I do.

This command has tons of optional parameters that decide the amount of details and items to show. You can view all of them using the help command by typing dir /? but we will explain some of them here for clarity.

Parameter Example Explanation
/A:ATTRIBUTE or /A:-ATRRIBUTE dir /A:D
dir /A:R
dir /A:H
dir /A:-D
dir /A:-D-H
Show all folders
Show Read-Only files
Show Hidden files
Do NOT show folders
Do NOT show folders or Hidden Files
/O:SORTINGORDER or /O:-SORTINGORDER dir /O:N
dir /O:S
dir /O:D
dir /O:E
dir /O:D-N
Sort by filename
Sort by file size
Sort by Date & Time
Sort by File Extension
Sort by Date & Descending Filename
/T:TIMEMODE dir /T:C
dir /T:A
dir /T:W
Sort or view by Creation time
Sort or view by Last Access time
Sort or view by Last Written time
/S dir /S Include all sub-folders
/B dir /B Bare format (no header, size, or summary)
/L dir /L Use lowercase letters
/Q dir /Q Show the owner of the file
/N dir /N Long format with filenames on the right
/X dir /X Long format with short filenames
/C or /-C dir /C Include/Hide thousand separator in file size

Launch and Application or Program

The last thing that you should know when navigation through your system in command prompt is how to start an app through it. Thankfully it’s as simple as navigating to the correct folder and typing the name of the executable.

For example, if for whatever twisted reason you wanted to start up another command prompt instance from within the command prompt, you can do that. First you need to navigate to System 32 folder with cd /d C:/Windows/System32 and then type in start cmd to launch a new instance of cmd.

You can also start an app simply through the full file-path. For example, to launch MS Paint you can type in C:/Windows/System32/mspaint.exe and the software will start up instantly.


File & Folder Editing

File and folder editing is the bread and butter of the command prompt. These are the main commands you will be taking advantage of when using cmd. Once you get the hang of the navigation first, you will be ready to get going with the editing itself.


Make Directory (md)

The first command will let you create a new folder or directory. The md command is an alias for the longer version mkdir which both do the same thing. As long as you remember one of them, you’re good to go.

In order to create a new folder in the current working directory, type md FOLDERNAME. You can also create multiple nested folders by just adding them in with slashes. For example, if you want to create folders and sub-folders at once, type in md TechTipVault/SubFolderName/EvenDeeperFolder and now you have a triple layered folder hierarchy.

If you want to create multiple folders within the same directory, you need to separate the folder names with white-space. For example, in order to create 3 folders within the active directory, type up md Folder1 Folder2 Folder3 and now you have three new folders to work with.

It is good to note that white-space or special characters like commas, equals or semicolons will separate multiple folders. This means if you want to add special characters or spaces within the folder names, you need to add the folder name between quotation marks. For example, to create two folders with spaces in the names, you can type md "Folder 1" "Folder 2 = Folder 2". Now you will have 2 new folders, one called Folder 1 and the other one called Folder 2 = Folder 2.

Finally, you can create a folder with the above commands directly into any location by writing the entire path after the command. For example, if you are currently in C:/Users folder, you can type md X:\TechTipVault\EpicFolder to create a new folder on a different drive. Make sure to use back-slashes for the path or it won’t work.

Command Prompt Make Directory Commands

You can use the up-arrow key to move back to previously used commands.

Rename Files & Folders (ren)

The rename command is one of the most useful commands cmd has to offer. It allows you to rename any files and even change their extensions, transforming the file into a different type.

Simply renaming a file can be done by typing ren tipvaulttech.txt TechTipVault.txt in order to name the file into the latter format. You can also use this same syntax to rename a folder.

As you might expect, you can use the same logic to change the extension of a file. By typing ren TechTipVault.txt TechTipVault.html you will change your text file into an html file.

The best part about the renaming syntax in the command prompt is the ability to use wildcards. You can use * and ? characters to make complicated naming scenarios very easily.

Below is an interesting example utilizing the forward slash, which is not really documented anywhere, but a fun use-case can be seen utilized to remove parts of the filename.

Initial Song Names before Rename Command ren "Artist - " "/////////.*"
(Add same amount of slashes as
characters found on the left side)
Final Song Names before Rename Command

The * symbol basically means every character before the character that follows it. For example, if you wanted to transform every text file in a folder into log files, you could accomplish this by typing ren *.txt *.log noting the space(s) in between. The first “*” takes the original name and the second “*” replaces any character after (and including) the dot with .log.

The ? symbol finds the next character after it and appends it to the target name (as long as the next character is not a .). If the next character is a . then no character will be added in to the result.

For example, if you add 5 question-marks, it will replace 5 (or less) characters before a dot. See the examples in the table below.

If both are combined *?, they will append all remaining text from the source name to the target name and vice versa.

Initial Files Command Final Files
ttv.txt
TechTipVault.html
file1.xyz.log
1. ren *.* *.
2. ren * *_NEW.log
ttv_NEW.log
TechTipVault_NEW.log
file1.xyz_NEW.log
abc.abc
12345.12345
ABC123.docx
TechTipVault.Backup.log
ren * ????.????
(4 times ? on each side)
abc.abc
1234.1234
ABC1.docx
Tech.Back
ttv.txt
TechTipVault.xxx.dat
a.b.c_d
ren * *?.bak ttv.txt.bak
TechTipVault.xxx.dat.bak
a.b.c_d.bak

Copy Files & Folders (copy |xcopy)

When looking to copy things, it’s good to note that there are two separate commands you need to use. You have to use the copy command in order to copy files and the xcopy command to copy folders and their contents. Both of these commands also have their own parameters and options to give you more options.

Copy Files (copy)

Let’s first go in-depth with copying files using command prompt. The simple and easy basic functionality of this command is copy filename.ext newfilename.ext which will copy the file with a new name in the active directory.

Similar to most of the other commands, you can copy files from the active directory to a different folder or drive by adding their separate paths. For example, copy "C:/Users/TechTipVault/Epic Text File.txt" "X:/TechTipVault/CopiedVersion.txt" will copy a file (even with white-space in the name) from the C-drive to the X-drive.

A unique feature with this command is the possibility to merge text files into a single new text file. For example, if you want to merge every text file in a folder into a single one, you can use copy *.txt "\TargetDirectory\CombinedFileName.txt" and you now have a nice wombo-combo. Check the example below.

Command Prompt File Copying - Initial FilesCommand Prompt File Copying - Required CommandsCommand Prompt File Copying - Final File

Copy Files and Folders (xcopy)

Now let’s dive into the xcopy command. It is very similar to the normal copy command but provides more parameters and switches to take advantage of.

The basic syntax for copying files with xcopy is the same as with the normal copy command, which is why you should use that one instead. The main reason for this is because when using xcopy, you can’t tell if the target should be a file or a folder. If you do this, you will be prompted to enter either ‘F’ for file or ‘D’ for directory into the command prompt. In order to ignore this prompt and default as a file, you can add a wildcard (*) to the end of the target as such xcopy source.txt target.txt*

Command Prompt XCopy for Files

Finally, there are a few parameters you should be aware of with xcopy, although most of them are not very useful. You can type xcopy C:\Users\TechTipVault\FolderWithStuff X:\TechTipVault /S /I in order to copy every file, subfolder and files in the subfolders to the target folder. Here you can see the most important parameters that can be combined with the xcopy command.

Parameter
(Usage: xcopy source target parameter)
Explanation
/S Copy folders and sub-folders
(including files within them) (excluding empty folders)
/E Copy folders and sub-folders
(including files within them) (including empty folders)
/I Assume the target is a Folder (type)
/Y Suppress the prompt for overwriting files. (Overwrites duplicates without warnings)
/T Copy entire folder structure, but ignore any files.
(/T /E combo will also include empty folders and subfolders)
/K Copy attributes (otherwise things like read-only attributes will be reset)

Modify File Attributes (attrib)

The attribute command is quite a simple but useful affair. It allows you to display a files attributes or change them to your liking. Attributes mean features like being Read-only or hidden files.

With this command you can add an attribute with a + symbol and disable an attribute with the - symbol. The two basic attributes you will be using are R for Read-only and H for Hidden. The Hidden parameter also works for folders, but the Read-only attribute can only be applied to files. There are also A for Archive and S for System attributes, but they are rarely used.

You can also use the /S modifier to apply the attributes to all files within sub-folders as well and /D to apply the changes to selected folders too. As with most file editing commands, you can also use wildcards with the attrib command to easily modify a group of files instead of just one.

The basic syntax to make a file hidden and remove its read-only property can be done as follows: attrib +h -r SuperSecretPasswords.txt


Delete Files (del)

The delete command is unsurprisingly quite self-explanatory. It can be used to delete files. However, it is not possible to remove folders with it, as that’s what the remove directory command is for, discussed below.

Thankfully, to make the del command a little more useful, it includes plenty of parameters for more specific deletions alongside the ability to use wildcards for filenames. As for basic usability, you can type one or multiple filenames after the command as such: del file1.docx "Tech Tip File.log" "X:\TechTipVault\File.txt"

A cool feature of the del command is if you use it on a folder, all the files within the folder will be deleted but the folder itself will remain intact.

Command Prompt Delete Folder Contents

Now let’s get to the parameters you can use alongside the delete command. Here’s a quick list of the useful ones:

Parameter
(Usage: del parameters /A:attributes filesToDelete)
Explanation
/F Ignore read-only settings and force-delete the file
/Q Don’t show Yes/No prompt when deleting file
/A Use this before adding file attributes (/A:format)
/A:R or /A:-R Delete files that are Read-only or not Read-only
/A:H or /A:-H Delete files that are Hidden or not Hidden

You can combine multiple attributes by adding multiple of the parameters after the /A: syntax. There are a few more attributes, but rarely used in default cases. If you would like to learn more about them, check the documentation for the command with del /? syntax.


Remove Directory (rd)

The remove directory command is a very simple alternative to the delete command, but it allows the deletion of folders. The rd command doesn’t allow for the use of wildcards and only has 2 parameters, which makes it a lot easier to remember.

The usage of this command is simple, you can delete any amount of folders and their contents by simply typing rd FolderPath but without parameters, it will only delete an empty folder.

The parameters include: /S which deletes all files and sub-folders alongside the folder itself and /Q which will remove the Yes/No prompt on deletion. For example, rd /S /Q "X:\TechTipVault\GarbageFolder\" will delete the whole GarbageFolder and all of its contents without asking for confirmation for the deletion.


Advanced Command Prompt Commands

This is going to be the most exciting section of the entire command prompt ultimate guide. We will feature all the awesome commands you can use to find tons of useful information about your system and do things like repair corrupt files. These are the commands you will find yourself using over and over again and will want to tell your friends about.


Check All File Associations (assoc)

This command allows you to view or change what a file extension stands for. The basic usage is as simple as assoc .txt to find out what program the .txt extension is associated with.

If you want to add or change an association to a file extension, you can use similar syntax as to what you receive as a result from the base command. For example, if you want to associate the .log extension as a text file, you can type assoc .log=txtfile.

Similarly, if you would like to remove a file association, you can just type assoc .log= and execute the command.


File Comparison (fc)

The file comparison is another interesting command. You can use it to find differences in files using binary or ASCII format. If you want to compare files with an ASCII format comparison, you need to add /a after the command and in case of binary comparison, add /b after the command. Then just enter the filenames or paths to compare.

You can also add /number like /1 which is the number of lines that need to match for the file to be considered synchronized. It is quite difficult to explain clearly, which is why I highly recommend you do some testing on your own to really notice how the differences are laid out (we also added some pictures below to explain this further). Another very useful parameter is /n which will show the line numbers next to the text lines within the command prompt.

The basic formatting of the differences in the command prompt results are as follows:

  1. Name of the first file
  2. First row that matches
  3. Differences
  4. Second row that matches after the differences
  5. Name of the second file
  6. Same as steps 2-4 but for the second file
  7. Rinse and repeat

Command Prompt File Comparison DifferencesCommand Prompt File Comparison With 1 Line

Click to enlarge image
Command Prompt File Comparison With 2 Lines
Click to enlarge image

The use-cases for binary comparison (/b) are a lot more limited, as most end-users won’t have need for it. It’s best used when trying to find out if two non-text files are duplicates. This can be useful when looking for duplicate images with different names, for example, as the binary differences will show up.


Check IP-Address & Network Information (ipconfig)

This is without a doubt the most well-known command out of anything we list here. Everyone who has done any gaming or connection related things, has probably used ipconfig to find out their IP-address.

There’s not much to explain about ipconfig as what you see is what you get with the results. However, the command has a few cool parameters you can take advantage of to see more information and perform a few unique functions as well.

Probably the most useful parameter for this command is the /all command which shows the full TCP/IP configuration for all your network adapters. This way you will see all the information you need and there’s really no reason not run the command with this parameter every time.

Another very useful option to use with ipconfig is the /flushdns parameter. You can use it to clear your DNS cache. On the same note, you can also view your DNS cache with /displaydns to see if you should be clearing it up with the previous parameter.

For clarification, a DNS or a domain name server basically converts a domain name or URL (for example techtipvault.com) into an IP-address that the computer can understand and connect to. You system hold a record of these conversions to speed up repeated requests to same addresses and that record is called the DNS cache.

The reason why you might want to flush your DNS cache is because sometimes there’s out-dated conversions if a website has moved to a different server for example. You can flush your DNS cache to update those records on the next connection attempt.


See All Your Active Connections (netstat)

You can use the Network Status or netstat command to view all the connections going out and coming in to your machine. This command is mostly popular among Indian tech support scammers as they attempt to convince their victims there are hackers connected to the PC by typing in this command.

This command also a has a few parameters to increase its functionality. For example, you can use -a to display all connections and listening ports. You can also check out your Routing table by adding in the -r parameter.

Probably the most useful parameter that can be used with netstat is -b which will display the executable names with which each connection is associated with. This means you can easily see which connections are attached to your web browser or any other process.

Finally, you can add a number to the end of the command after all the parameters to indicate how fast you would like to automatically repeat the command (in seconds). If you don’t add a number, the command will only execute once. Typing netstat -b 10 would show the executable above each connection and command would repeat once every 10 seconds. In order to stop the repetition, you need to press Ctrl + C.


Show Optimal Route to Target Address (tracert)

The Trace Route or tracert command will tell you the optimal route from your system to the target IP-address or URL. It will also show that exact route step-by-step and tell you how long it took between each step or hop. It is fantastic for troubleshooting issues within large networks as many different paths can be acquired to arrive to a target machine.

The command has a default limit of 30 hops which means it will attempt to find the fastest route within 30 jumps from one router to the next. You can use the -h parameter to change the max hops, so tracert -h 10 techtipvault.com would use a maximum of 10 hops to reach the target.

TraceRoute With Command Prompt

Conveniently, you can also see the IP address if you type in a URL. This can also be accomplished without the hops using the ping command, explained below.

It is also good to note that trace route shows the most optimal route, not always the ACTUAL route it takes.


Send Test Packet & Check Connection to Target Address (ping)

The ping command is used to test or ping the target IP-address to see if there’s any issues in the connectivity. It is very similar to the tracert command, but pinging is quicker as it just tells you if a specified target can be reached and how long it takes to send and receive packets to that target server.

It is as quick and simple to use as typing ping techtipvault.com to see the target IP-address as well as response times.

The ping command has a lot of optional parameters to use, but most of them are not useful for most users so if you’re interested, you should check out the information page by typing ping /? into the command prompt. The most useful one is probably -n number to specific the amount of ping attempts and -w number to specify how long to wait for each reply from the server in milliseconds.


Lookup the IP-Addresses on a Nameserver (nslookup)

The name-server lookup command in its simplest form is a way to find what IP addresses belong to a target address. This can be done simply by typing nslookup techtipvault.com to find the connection details.

Command Prompt NSLookup

This command has a special Command Mode which can be accessed by typing the command without any parameters. Doing this will activate a mode where you can execute a bunch of unique commands to do name-server testing. You should check the command prompt info page (nslookup /?) for the special commands, as there are too many of them to explain here.

If you wish to exit the Command Mode, you can simply use the Ctrl + C keyboard shortcut.


Check Your System Specifications & Drivers (systeminfo | driverquery)

The System Info command is a great tool to quickly check your operating system information and other info like how much RAM you have installed. It is organized in a neat list so it’s easy to read and even copy if needed.

You can also see your network card information as well as Hyper-V requirements which are needed by some monitors and features like Miracast. It is possible to check remote system info as well by typing systeminfo /S targetSystem /U username /P password, noting you don’t need to use the username and password parameters if nothing is set-up for them.

To see a comprehensive list of all the drivers operating on your system, you can use the driverquery command. It uses the same syntax for remote connecting username and password wise as seen above.


Get a Power Efficiency Report of Your System (powercfg)

This is an interesting utility which allows you to see all kinds of information about your power usage. There are tons of parameters to take advantage of to view and modify your power schemes among other things.

The most useful one is powercfg /energy which will run a 60 second test of your computers power efficiency. The command will save a full report as an html file in your active directory so you can see any potential issues in full detail.

Command Prompt Power Efficiency Report

To check the other commands, again, type in powercfg /? to see what parameters are available for use.

Note that you need to run the command prompt as administrator to use this command.


Check the Integrity of Your Files and Fix Them (sfc)

The System File Scan is a great utility to make sure you don’t have any corrupted system files on your machine. The command will basically scan all of your protected system files and check their integrity.

The most useful and popular command is the /scannow parameter, which scans all the files and replaces any faulty ones with the official Microsoft files. Sometimes it might require the official installer files to replace them, so you need to follow any instructions given if this is the case.

The simpler version of this parameter is /verifyonly which does the same scan telling you of any problems, but it won’t do any repairs unlike the prior command.

Similarly, you can use /scanfile to check and repair a specific file or /verifyfile to check the integrity of a file, but no automatic repairs are done. With these parameters, you need to add the full path to the target file after an equals sign like so: sfc /scanfile=C:\Windows\System32\kernel32.dll


Scan Entire Drive or Disk for Issues (chkdsk)

The Check Disk command is a more impressive version of the Scan Disk command. With this command you can scan an entire disk for issues and repair them automatically.

The base use of the Check Disk command is chkdsk C: /F which stands for fix any corrupted files. It is important to note that when you run this scan, it will count any currently opened files as errors as well. This means it’s best to check the disk when booting up the PC with nothing open yet.

You should be aware that checking the disk can last a very long time depending on the number of files and your processing power. It’s also good to note that you can’t do anything or modify files on the disk being scanned, so it’s best to let then scan run and not touch the system while it’s running.

Here are some of the more useful parameters that can be used with the chkdsk command:

Parameter
(Usage: chkdsk /parameter)
Explanation
/F Fix any errors on the disk
/R Recover any bad sectors and recover readable information
/X Makes the specified disk dismount first, closing all open files and processes running from it
/C Skip checking for corrupt folders, only check files
/scan Run a scan online, checking for fixes on issues from the internet
/scan /perf The perf parameter can only be used alongside scan to perform the scan a lot faster.
This can slow down all other processes on the system during the scan.
/sdcleanup Cleans up unnecessary security descriptor data from storage

Find and Kill Any Running Task (tasklist | taskkill)

You can use the tasklist command to see all currently running tasks on your system, similar to the Task Manager. It might be somewhat redundant due to the simplicity of the Task Manager, but it can show some tasks that are not otherwise visible as well as the memory usage in a cleaner format, within command prompt.

If you wish to force-close a process, you should first take note of the name or process ID (PID) from the task list. Once you have decided on one, you can type either taskkill /im AppName to close an application by name or by typing taskkill /pid processID to kill it by its ID.

In some cases, this can be useful, for example if you want to make a batch script to close certain processes automatically when you start playing a game or boot up your machine. There are also plenty of additional parameters to be used with tasklist to sort it in a fashion you prefer.


Command Prompt Shortcut Keys

Here are the best and most useful keyboard shortcuts for command prompt. These will definitely speed up your performance with the command prompt and you can always return to this table for a quick refresher.

Shortcut Explanation
Up/Down arrow key Select the previous/next commands you’ve previously executed.
Right arrow key Repeat the previous command you’ve executed one character at a time.
Ctrl + Right/Left arrow key Move the marker before the first character of the next or previous word.
Ctrl + Up/Down arrow key Scroll up or down on the command prompt without moving the marker.
Ctrl + A Select all written text on the current row and press the combination again to select everything within the cmd.
Shift + Right/Left/Up/Down arrow key Increase the amount of text currently selected by one character left/right, or a full row up/down.
Ctrl + C / Ctrl + V Copy / Paste text to and from the command prompt. Copying requires text to be selected first.
Ctrl + Backspace Delete the word left of the marker.
Escape (Esc) Delete the entire row of text.
F1 Repeat the previous command you’ve executed one character at a time.
F2 Repeat a portion of the previous command up to a specified number (or all of it).
F3 Repeats the entire previous command.
F4 Deletes a command up to a specified number (or all of it).
F5 Repeats the last command without cycling more previous commands.
F6 Pastes “^Z” to the current row.
F7 Gives you a list of previously executed commands.
F8 Repeats previously executed commands in a cycle (keep pressing for more).
F9 Allows you to paste a previously executed command from the list (list obtained from F7).

Edit the Look & Colors of Command Prompt

Now that you know all the good stuff there is to know about the Windows cmd, it’s time to customize it a little bit. There are a few commands available for customization. You can do things like change the font or background colors, title of the command prompt window and change the font itself.

Changing the title of the command prompt is quite a useless command unless you are creating scripts and want to showcase your name or company in it. The command doesn’t save the title after the prompt is closed. However, you can change it to whatever you want by simply typing title TechTipVault.com Command Prompt or whatever name you wish.


Change Background & Font Color

First and foremost, let’s figure out how to change the font and background colors. Thankfully it’s extremely simple as all you need to do is type color and 1 or 2 color codes.

The first character in the parameter is the background color and the second character is the font color. If you only enter one character, it will change the font color and the background will default to black.

So, if you wanted a red font and a bright white background, you could type color F4. To change the color scheme back to the default options, type in color without any parameters.

Command Prompt Color Codes Red Colour Scheme Command Prompt

Change the Font Style

In order to change the font used in cmd, you need to first access the properties of the window. You can do this by right-clicking on the title bar of the command prompt and selecting Properties.

Once opened, you might notice you can also change the above colors there as well, but the most useful tab is the Font tab. The options there are very self-explanatory. At the top you can choose your font-size and below it you can pick a font family of your choosing.

Changing Font In Command Prompt

You can also tick the Bold fonts checkbox to bold all fonts and you can see the preview of what your selection will look like at the bottom.

Now that you’ve read through the entire guide, you should have a firm grasp on the functionality of the Command Prompt. There’s tons of parameters and commands not covered in this guide, as it would become way too cluttered and hard to read. We highly recommend you go through all the command manuals within cmd and try as many of them out yourself to understand how they work in-depth.

If you noticed any issues with the contents or think we should add some clarifications, don’t hesitate to contact us. You can find our contact details on our About Us page.

  • Windows command net command что это
  • Windows command processor грузит процессор
  • Windows command line windows version
  • Windows command line zip command line
  • Windows command line open file