How to use cmd in windows

There is an easy way to impress your friends. Including some basic commands and even a hacking tutorial, this is the perfect place to start. Open Command Prompt. Head over to the Start menu. Search "cmd" there.


Download Article


Download Article

There is an easy way to impress your friends. Including some basic commands and even a hacking tutorial, this is the perfect place to start.

  1. Image titled Use CMD (Beginner) Step 1

    1

    Open Command Prompt. Head over to the Start menu. Search «cmd» there.

    • You can also hit Run, then search for it.
    • If both of those don’t work, you will need a slightly more complex method. Open Notepad. On the top line write «Command.com»  (without the quotation marks.) Save it as CMD.bat. The .bat part is VERY important. And that’s it. Open it using whichever method you chose.
  2. Advertisement

  1. Image titled Use CMD (Beginner) Step 2

    1

    Change color. The first command, and one of the simplest, is «color». You can change the color of the text and the background. You start off with a gray-ish text and a black background. Type in «color help» for a full list of all the combinations you can make.

    • A fun combo is «color FC» which provides with red text on a white background.
    • «Color 0a» uses bright green on black, which may seem drab, but is actually a cool hacker look. Experiment!
  2. Image titled Use CMD (Beginner) Step 3

    2

    Try «cls». Another command, which is vital, is «cls». It’s very simple. Basically, if you have a lot of mumbo-jumbo on the screen, «cls» will clear it to just showing the prompt. If you don’t know what the prompt is, use «cls» and find out, though it’s not important.

  3. Image titled Use CMD (Beginner) Step 4

    3

    Adjust the title, if desired. If you were to look at the top of the CMD window, you would notice it would say:   C:Windowssystem32cmd.exe. A bit boring, isn’t it? Type «title» followed by whichever text you wish to be there instead. For example, «title This Tutorial Rocks!» And… BOOM! It’s there!

  4. Image titled Use CMD (Beginner) Step 5

    4

    Use «tree.» None of these will really blow the socks off your friends. If you really want to impress them try «tree» and wait for results. «Color 0a» is good for this. What «tree» does is it makes a graphical directory. For those who don’t know what that means don’t worry. It is very cool. However, if you are using a school computer, or anything like it, the tree will probably be small and stupid. It won’t be cool.

  5. Image titled Use CMD (Beginner) Step 6

    5

    Experiment with «help.» And finally, the last basic command for a beginner — «help». It looks cool opening, and is very useful. It will provide a lot of room for experimentation.

    • This last step in basic commands isn’t actually a real command: «/?» Adding that to the end of a command will give a help menu to that specific command.
  6. Advertisement

  1. Image titled Use CMD (Beginner) Step 7

    1

    Be warned — hacking is Illegal! Use this information at your own risk.

  2. Image titled Use CMD (Beginner) Step 8

    2

    Change a password. Unfortunately, you need to have administrator privileges. Type «net user USERNAME * » (remember the SHIFT-8 for asterisk.) And that is that.

  3. 3

    Ddos a site. Type ping url of the site in cmd and press enter you will see the ip address of the site.Then type ping ip address of site -t -l 6650 and look at your target site after 1-2 hours it will fail.But now many sites have ddos protection

  4. Advertisement

Add New Question

  • Question

    Is learning CMD useful?

    Luigi Oppido

    Luigi Oppido is the Owner and Operator of Pleasure Point Computers in Santa Cruz, California. Luigi has over 25 years of experience in general computer repair, data recovery, virus removal, and upgrades. He is also the host of the Computer Man Show! broadcasted on KSQD covering central California for over two years.

    Luigi Oppido

    Computer & Tech Specialist

    Expert Answer

    Yes, but only if you have a higher level understanding of the machine. If not, if you’ve just gone to the command prompt because someone told you to do that, sometimes the command prompt will supersede other issues. If you’re in the Command Prompt, you have to type exactly what you want, or it’s not going to work.

  • Question

    How can I start a new prompt?

    Community Answer

    In order to clear the screen on the command prompt, just type in ‘cls’ and hit enter or type ‘start’ to open a new window.

  • Question

    How can I modify a game?

    Community Answer

    If you want to mod a game, then CMD may not work. Some games support modification using 3rd party programs (Minecraft supports Forge for modding). Search the internet for instructions on how to mod the game you want.

See more answers

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

Submit

Advertisement

About This Article

Thanks to all authors for creating a page that has been read 74,931 times.

Reader Success Stories

  • Kostas Kamaris

    Kostas Kamaris

    Nov 20, 2016

    «I am new to Command Prompt, and this helped me a lot! What a great website.»

Is this article up to date?

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:WINDOWSsystem32 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:WINDOWDSsystem32 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:TechTipVaultEpicFolder 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 "TargetDirectoryCombinedFileName.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:UsersTechTipVaultFolderWithStuff 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:TechTipVaultFile.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:TechTipVaultGarbageFolder" 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:WindowsSystem32kernel32.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.

Ezoic


Updated: 12/31/2020 by

Windows command line (DOS)

This page covers the basics of navigating and using the Microsoft Windows command line. On this page, you learn how to move around in the command line, find files, manipulate files, and other important commands. Realize that there are over 100 different commands used in MS-DOS and the Windows command line. If you are interested in learning about the command line in more detail, see our DOS and command prompt overview, which gives a description and example for every command.

Get into the Windows command line

Open a Windows command line window by following the steps below. If you need additional information or alternative methods for all versions of Windows, see: How to get to an MS-DOS prompt or Windows command line.

  1. Click Start.
  2. In the Search or Run line, type cmd (short for command), and press Enter.

Understanding the prompt

After following the steps above, the Windows command line should be shown (similar to the example below). Windows often starts you at your user directory. In the example below, the user is Mrhope. So, C:UsersMrhope> is our prompt. This prompt shows that we’re in the C: drive (default hard drive letter) and currently in the Mrhope directory, a subdirectory of the Users directory.

Windows command line

Key tips

  • MS-DOS and the Windows command line are not case-sensitive.
  • The files and directories shown in Windows are also found in the command line.
  • When working with a file or directory with a space, surround it in quotes. For example, the directory My Documents would be «My Documents» when typed.
  • File names can have a long file name of 255 characters and a three character file extension.
  • When a file or directory is deleted in the command line, it is not moved into the Recycle Bin.
  • If you need help with any of command, type /? after the command. For example, dir /? would give the options available for the dir command.

Listing the files

Let’s learn your first command. Type dir at the prompt to list files in the current directory. You should get an output similar to the example image below. Without using any dir options, this is how dir output appears. As shown, you are given information including the creation date and time, directories (<DIR>), and the name of the directory or file. In the example below, there are 0 files listed and 14 directories, indicated by the status message at the bottom of the output.

Listing files in the Windows command line

Every command in the command line has options, which are additional switches and commands that can be added after the command. For example, with the dir command, you can type dir /p to list the files and directories in the current directory one page at a time. This switch is useful to see all the files and directories in a directory with dozens or hundreds of files. Each of the command options and switches is listed in our DOS command overview. We offer guides for individual commands, as well. For example, if you want to see all the options for the dir command, refer to our dir command overview for a complete option listing.

The dir command can also be used to search for specific files and directories using wildcards. For example, to list files or directories that begin with the letter «A» you could type dir a* to list only the AppData directory, in this above example. See the wildcard definition for other examples and help with using wildcards.

  • How to list files in a directory or folder on the computer.

Moving into a directory

Now that we’ve seen a list of directories (shown below) in the current directory, move into one of those directories. To move into a directory, we use the cd command, so to move into the Desktop type cd desktop and press Enter. Once you’ve moved into a new directory, the prompt changes. So, in our example, the prompt is now C:UsersMrhopeDesktop>. You can see what files are found in this directory by typing the dir command again.

Windows command line listing Desktop files

  • How to change a directory or open a folder.

Understand the files

In the Desktop directory, as shown in the above example, there are 23 files and 7 directories, representing different file types. In Windows, you are familiar with files having icons that help represent the file type. In the command line, the same thing is accomplished by the file extensions. For example, «forum posts.txt» is a text file because it has a .txt file extension. Time.mp3 is an MP3 music file and minecraft.exe is an executable file.

  • Listing of file extensions and additional help with file extensions.

Most users are only concerned with executable files, which as mentioned above, are files ending with .exe, .com, and .bat. When the file name is typed in the command line, the program runs, which is the same as double-clicking a file in Windows. For example, if we wanted to run minecraft.exe, typing minecraft at the prompt runs that program.

Note

Realize that if the executable file you are trying to run is not in the current directory, you get an error. Unless you have set a path for the directory with the executable file, which is how the command line finds external commands.

If you want to view the contents of a file, most versions of the command line use the edit command. For example, if we wanted to look at the log file hijackthis.log, we would type edit hijackthis.log at the prompt. For 64-bit versions of Windows that do not support this command, you can use the start command (e.g., type start notepad hijackthis.log) to open the file in Notepad. Additional information about opening and editing a file from the command line is available on the page linked below.

  • How to open, view, and edit the contents of a file on a computer.

Moving back a directory

You learned earlier the cd command can move into a directory. This command also lets you go back a directory by typing cd.. at the prompt. When this command is typed, you’ll be moved out of the Desktop directory and back into the user directory. To move back to the root directory type cd to get to the C:> prompt. If you know the name of the directory you want to move into, you can also type cd and the directory name. For example, to move into C:Windows>, type cdwindows at the prompt.

  • How to change a directory or open a folder.

Creating a directory

Now with your basic understanding of navigating the command line, let’s start creating new directories. To create a directory in the current directory, use the mkdir command. For example, create a directory called «test» by typing mkdir test at the prompt. If created successfully, you are returned to the prompt with no error message. After the directory is created, move into that directory with the cd command.

  • How to create a directory or folder.

Switching drives

In some circumstances, you may want to copy or list files on another drive. To switch drives in the Windows command line, type the drive letter of the drive followed by a colon. For example, if your CD-ROM drive is the D drive, you would type d: and press Enter. If the drive exists, the prompt changes to that drive letter. If the drive does not exist or is not accessible (e.g., no disc in CD-ROM drive), you get an error.

  • How to copy files from one drive to another drive.
  • How to change drives in MS-DOS and Windows command line.

Creating a new file

You can create a new file from the command line using the edit command, copy con command, or using the start command to open a file.

  • How to create a file in MS-DOS and the Windows command line.

Creating a new batch file

In the new test directory, let’s create your first file. In most circumstances, you never need to create any file at the command line, but it is still good to understand how files are created. In this example, we are creating a batch file. A batch file is a file that ends with .bat and helps automate frequently used commands in the command line. We are calling this batch file example, so type edit example.bat at the prompt. As mentioned in the document on creating a file, if the edit command does not work, use the start command to open the batch file in Notepad. To perform this action, you type start notepad example.bat into the prompt.

Both of the commands above open a new blank example.bat window. In the file, type the three lines below, which clear the screen with the cls command and run the dir command.

@echo off
cls
dir

After these three lines are typed into the file, save, and exit the file. If you are in the edit command, click File (or press Alt+F) and then Save. After the file is saved and you are back at the command prompt, typing dir displays the «example.bat» file in the test directory.

Now, run the batch file to get a better understanding of what a batch file does. To run the batch file, type example at the prompt, which executes the batch file, clears the screen, and runs the dir command.

  • Full information and additional examples on batch files.

Moving and copying a file

Now that we’ve created a file, let’s move it into an alternate directory. To help make things easier, create another directory for the files. So, type mkdir dir2 to create a new directory in the test directory called dir2. After the new directory is created, use the move command to move the example.bat file into that directory. To do this, type move example.bat dir2 at the prompt. If done successfully, you get a message indicating the file was moved. You could also substitute the move command for the copy command to copy the file instead of moving it.

  • How to move files and folders on the computer.
  • How to copy files.

Rename a file

After the file is moved into the dir2 directory, move into that directory with the cd command to rename the file. In the dir2 directory, use the rename command to rename the example file into an alternate name. Type rename example.bat first.bat at the prompt to rename the file to «first.bat.» Now, when using the dir command, you see «first.bat» as the only file.

Tip

When renaming any file, make sure the file has the same file extension. If you were to rename the .bat file to a .txt file, it is no longer an executable file only a text file. Also, realize that renaming the file to a different file extension does not convert the file. For example, if you renamed the file as an .MP3, it may look like an MP3 in Windows, but it’s not going to play music.

  • How to change or rename a file, folder, or directory.

Deleting a file

Now that we’ve had our fun with our new file, delete the file with the del command. Type del first.bat to delete the first.bat file. If successful, you are returned to the prompt with no errors, and the dir command shows no files in the current directory.

Tip

When deleting files, you can also use wildcards to delete multiple files at once. For example, if the directory contained several .GIF image files you could type del *.gif to delete all files ending with the .gif file extension.

  • How to delete a file, directory, or folder.

Renaming a directory

Go back one directory to get back to the test directory using the cd.. command mentioned earlier. Now, rename our dir2 directory to something else using the same rename command we used earlier. At the prompt, type rename dir2 hope to rename the directory to «hope.» After this command is completed, type dir and you see one directory called «hope.»

  • How to change or rename a file, folder, or directory.

Removing a directory

While still in the test directory, remove the hope directory using the rmdir command. At the prompt, type rmdir hope to remove the hope directory.

Tip

If the directory you are trying to remove contains any files or directories, you’ll receive an error. To prevent this error, use the /s option. For example, if the hope directory still had the first.bat file, you would need to type rmdir /s hope at the prompt.

  • How to delete a file, directory, or folder.

Running a program

Any executable file can run from the command line by typing the name of the file. For example, if you listed files using the dir command and see a file named «myfile.exe,» typing «myfile» at the command line runs that program.

  • How to run a file from MS-DOS.

How to list available commands

After getting a good understanding of using the command line from the steps shown above, you can move on to other available commands by typing help at the command line. Typing «help» displays a list of available commands with a brief description of each command.

Closing or exiting the command line window

After you are done with the Windows command line, you can type exit to close the window.

In conclusion

Now you have a good understanding of how to navigate the command line, create directories and files, rename directories and files, and delete. As mentioned earlier, there are hundreds of other commands you can use at the command line. If you want to expand your knowledge further, we recommend looking at the options available for each command above and reviewing our commands overview page. You can also use our search to find any command by the name of the command or by the action it performs.


at

Starts commands and programs at a particular time. With the parameter /every:date[,…] you can also set regular appointments.

10/8/7/Vista/XP

auditpol

Displays current monitoring policies.

10/8/7/Vista

backup

Creates backups of files. These can be recovered with restore (replaced by msbackup).

DOS

bcdboot

Creates and repairs start files.

10/8/7

bcdedit

Allows users to make changes to start configuration data storage (the command is a new version of bootcfq).

10/8/7/Vista

bdehdcfg

Prepares a hard drive for BitLocker Drive Encryption.

10/8/7

bootcfg

Creates, edits, or displays the content of boot.ini (although it’s still included in the Windows 7 CMD, it has lost its function since boot.ini is no longer used for startup options, instead you should use bcdedit).

10/8/7/Vista/XP

bootsect

Modifies the master boot code sot that it’s compatible with the Windows Boot Manager or NT Loader (can only be started via system restore in Windows 7 and Vista).

10/8/7/Vista

cacls

Edits and displays the access control list. This sets access rights (outdated – replaced by icacls in newer Windows versions).

10/8/7/Vista/XP

chkdsk

Checks and repairs (with the parameter /R) a data drive.

All Win/DOS

chkntfs

Changes or displays the data driver check at startup.

10/8/7/Vista/XP

cmdkey

Can display (/list), create (/add), or delete (/delete) login information.

10/8/7/Vista

convert

Converts partitions from FAT/FAT32 to NTFS.

10/8/7/Vista/XP

ctty

Changes the standard input and output for the system.

98/95/DOS

dblspace

Creates or configures compresses drives (a newer version of the command is called drvspace)

.98/95/DOS

defrag

Defragments all or only specified drives. Use /U to observe the progress. To get an evaluation statistic after the defragmentation, use the parameter /V.

All Win/DOS

diskpart

Manages, creates, and deletes partitions from the hard drive.

10/8/7/Vista/XP

diskperf

Allows users to remotely control the disk performance counter.

10/8/7/Vista

diskraid

Manages RAID systems.

10/8/7/Vista

dism

Manages and integrates Windows images.

10/8/7

dispdiag

Creates a file in the current directory in which you’ll find information about your display.

10/8/7/Vista

dosx

Starts the DOS Protected Mode Interface, which allows MS-DOS programs more than 640 KB of RAM. Is only available to support older DOS programs.

32-Bit

driverquery

Creates a list with all installed drivers.

10/8/7/Vista/XP

drvspace

Creates or configures compressed drives. An older version of the command is called dblspace.

98/95/DOS

emm386

Provides DOS with more than 640 KB of RAM.

98/95/DOS

esentutl

Manages databases within the extensible storage engine.

10/8/7/Vista/XP

eventcreate

Creates an entry (ID and message) in an event log.

10/8/7/Vista/XP

eventtriggers

Configures and displays event trigger.

XP

fdisk

Creates, deletes, and manages partitions on the hard drive. Use diskpart in newer Windows versions.

98/95/DOS

fltmc

Allows users to manage and display filter drivers.

10/8/7/Vista/XP

fondue

Installs additional Windows features. The command is an abbreviation for the underlying tool: Features on Demand User Experience Tool.

10/8

format

Formats a drive to the file system specified by the user.

All Win/DOS

fsutil

Provides numerous features related to the file system, such as disk removal.

10/8/7/Vista/XP

hwrcomp

Compiles self-created dictionaries for handwriting recognition.

10/8/7

hwrreg

Installs a compiled dictionary for handwriting recognition.

10/8/7

icacls

Edits and displays the access control list. This sets access rights. An outdated version of this command is cacls.

10/8/7/Vista

ktmutil

Starts the kernel transaction manager.

10/8/7/Vista

label

Changes or deletes a drive’s label.

All Win/DOS

lh

Loads a program into the high memory area (UMB) – has the same function as loadhigh.

98/95/DOS

licensingdiag

Creates an XML and a CAB file that contain information on the Windows product license.

10/8

loadfix

Ensures that a program is loaded and executed above the first 64 KB of RAM.

32-bit/DOS

loadhigh

Has the same function as lh.

98/95/DOS

lock

Locks a drive so that only a user-selected program can access it directly.

98/95

lodctr

Updates all registry entries that have to do with performance indicators.

All Win

logman

Creates and manages event trace sessions and performance logs.

10/8/7/Vista/XP

manage-bde

Configures drive encryption with BitLocker. Use -on to encrypt a drive. Use -off to decrypt it again and end BitLocker protection.

10/8/7

mem

Displays information about the RAM and indicates which programs are currently loaded in it.

32-bit/DOS

memmaker

Optimizes the RAM.

98/95/DOS

mode

Configures system devices – primarily on the COM or LPT port.

All Win/DOS

mofcomp

Analyzes files in managed object format (MOF) and adds the classes and instances to the WMI repository.

All Win

mountvol

Creates and deletes mount points for drives and displays them.

10/8/7/Vista/XP

msav

Starts Microsoft Antivirus.

DOS

msbackup

Starts Microsoft Backup (replaces backup and restores).

DOS

mscdex

Loads the CD-ROM support for MS-DOS.

98/95/DOS

msd

Starts the program Microsoft Diagnostics, with which system information can be displayed.

DOS

msiexec

Starts the Windows installer, with which Windows can be installed and configured.

10/8/7/Vista/XP

muiunattend

Starts an automatic setup process for the multilingual user interface (MUI).

10/8/7/Vista

netcfg

Installs the minimal operating system Microsoft Windows PE.

10/8/7/Vista

ocsetup

Installs additional Windows functions.

8/7/Vista

pentnt

Recognizes floating point division errors in Pentium chips, starts floating point emulation, and disables floating point hardware.

XP

pkgmgr

Installs, uninstalls, and configures packages and functions for Windows.

10/8/7/Vista

pnpunattend

Automates the installation of device drivers.

10

pnputil

Installs plug-and-play devices from the command prompt.

10/8/7/Vista

power

Uses the IDLE status of a processor to reduce energy consumption.

98/95/DOS

powercfg

Allows the user to change the computer’s energy options and control energy conservation plans.

10/8/7/Vista/XP

pwlauncher

Configures the startup options for Windows To Go with which you can boot Windows from a USB drive.

10/8

qprocess

Provides information on running processes.

10/8/7/Vista

query

Displays the status of a particular service.

10/8/7/Vista

quser

Provides information on the currently logged-in users.

10/8/7/Vista

reagentc

Configures the Windows recovery environment, with which you can repair the installation of the operating system.

10/8/7

recimg

Creates a user-defined Windows image to restore the system.

8

reg

Manages the registry of the command prompt. Users can create new keys (reg add) or delete them (reg delete).

10/8/7/Vista/XP

regini

Changes registry authorizations.

10/8/7/Vista/XP

register-cimprovider

Registers a common information model provider (CIM provider) in Windows.

10/8

regsvr32

Registers a DLL file in the registry.

10/8/7/Vista/XP

relog

Creates new performance indicator protocols from the data in the existing protocols.

10/8/7/Vista/XP

repair-bde

Repairs and decrypts defective drives that are encrypted with BitLocker. The files should be saved on a replacement drive.

10/8/7

reset

Resets a session. You can also use the rwinsta command.

10/8/7/Vista/XP

restore

Restores backups that were created with the backup command (replaced by msbackup).

DOS

rwinsta

Command has the same function as reset.

10/8/7/Vista/XP

sc

Manages services by connecting to the Service Controller.

10/8/7/Vista/XP

scanreg

Repairs the registry and allows a backup to be created of it.

98/95

sdbinst

Applies user-defined database files (SDB).

10/8/7/Vista/XP

secedit

Analyzes the security settings by comparing the current configurations with templates. Settings can also be configured, imported, and exported with this command.

10/8/7/Vista/XP

setver

Sets a version number of MS-DOS that’s forwarded to a program – even if it doesn’t match the actual version.

32-bit/DOS

setx

Creates or changes environmental variable in the user of system environment.

10/8/7/Vista

sfc

Checks all important and protected system files. Incorrect versions are replaced by correct ones.

10/8/7/Vista/XP

smartdrv

Starts and manages the hard drive cache program SMARTDrive.

98/95/DOS

sys

Copies system files from MS-DOS and the command interpreter to another hard drive. This makes it bootable.

98/95/DOS

systeminfo

Displays information about the Windows installation, including all installed service packages. The information can be obtained from the local system as well as a remote computer.

10/8/7/Vista/XP

tpmvscmgr

Creates and deletes TPM virtual smart cards. These are virtual smartcards encrypted on the basis of the Trusted Platform Model.

10/8

tracerpt

Processes logs or real-time data generated during the tracing of computer programs.

10/8/7/Vista/XP

typeperf

Displays performance counter data or writes it into a file.

10/8/7/Vista/XP

unformat

Undoes the drive formatting done by the format command.

DOS

unlock

Unlocks a drive that was locked with the lock command.

98/95

unlodctr

Deletes names as well as descriptions for extensible performance counters in the Windows registry.

10/8/7/Vista/XP

vaultcmd

Creates, deletes, and displays saved registration information.

10/8/7

vol

Displays the label and serial number of a drive.

All Win/DOS

vsafe

Starts the antivirus software VSafe.

DOS

vssadmin

Manages the volume shadow copy services that can be used to store different versions (snapshots) of drives.

10/8/7/Vista/XP

wbadmin

Creates backups of the operating system and delivers information to the created backup copies.

10/8/7/Vista

wevtutil

Manages event logs and event log files.

10/8/7/Vista

whoami

Provides information about the current user. With the /GROUP parameter you can obtain additional information about group membership.

10/8/7/Vista

winmgmt

Manages WMI repositories. Backups (/backup) are possible with the command, for example.

All Win

winsat

Evaluates various system factors – for example, processor performance or graphical capabilities.

10/8/7/Vista

wmic

Starts the Windows Management Instrumentation in the command prompt. Various Windows settings can be changed here – both locally and on remote computers.

10/8/7/Vista/XP

xwizard

Registers Windows data in the form of XML files.

10/8/7

It’s much easier to troubleshoot problems on your PC when you know how to use the Command Prompt in Windows 10. There are multiple commands to use, so we’ve put together a useful list of the most common commands, as well as some less common options that will have you feeling like a command expert in no time.

Contents

  • The most useful commands
  • Lesser-known, but still worthwhile commands
  • A few additional tricks

Read on to learn all sorts of handy commands, like how to Ping, analyze your network connection, and even watch Episode IV of Star Wars.

The most useful commands

You don’t need to know all of the Command Prompt commands to find some use in it. These are our favorites and some of the ones we consider the most useful.

Help — Arguably the most important of all Command Prompt commands, typing “help” will give you a list of available commands. If you don’t learn anything else from this guide, know that “help” is only four short letters away if you ever fall down a CMD rabbit hole.

“command” /? — While it requires you to input a command in the quoted section (without the quote marks), this one will tell you everything you need to know about any of the commands on this list. It’s great to use if you want more detailed information about what the commands do and to see examples of how they work.

TRACERT — Should you want to track your PC’s internet traffic, this command lets you track the number of intermediate servers your packets go through, the time each transfer requires, and the name or IP address of each server.

IPConfig — If you have networking issues, IPConfig will be very useful for all sorts of reasons. Running it tells you a lot about your PC and your local network, including the IP address of your router, the system you’re using at the time, and what the state of your various network connections are.

Ping — Need to confirm whether your internet is officially down or if there’s just some software problem causing an issue? Ping something. It doesn’t matter whether it’s Google.com or your own personal remote server. Whatever you choose, if you get a response, you know a connection is there. This command is also useful for checking if local network systems are functioning properly.

Chkdsk — Check Disk, written as “Chkdsk,” looks at your chosen drive for errors. Although there are plenty of Windows and third-party tools for checking a drive for errors, Check Disk is a classic that works well and could save you from losing data if it finds a problem early enough.

SFC — Short for System File Checker, the command “SFC /scannow” will scan through all of the Windows system files to look for any errors and repair them if it can. Warning: This one can take some time.

Cls — Command Prompt command results might be useful, but they aren’t the most well organized or easy to read. If the screen is getting too full, just type “Cls” and hit enter to clear it.

Dir — If you’re using the Command Prompt to browse your file system, the “Dir” command will display all of the files and folders within the current folder. You can also add an /S and use it as a search when you want to find something specific.

Netstat — This command displays all sorts of information about existing connections to your PC, including TCP connections, ports on which your system is listening, Ethernet statistics, and the IPRouting table.

Exit — This does exactly what you would expect it to do. Don’t want to reach for the mouse or can’t seem to click that “X” in the top-right corner? Just type “exit” and hit enter to leave the Command Prompt behind.

Tasklist  Tasklist gives you immediate data on all the tasks that Windows is currently operating. You can add switches (such as “-m”) to dig down into more detail about these tasks and how they work, which is very useful for diagnosing any potential problems. It’s no surprise, then, that this is often followed up by the “Taskkill” command, which is used to force specific tasks to end.

Shutdown — Although you don’t necessarily need to shut down your Windows 10 PC at night, you can do it through the Command Prompt as well as the Start Menu. Just type “shutdown” and hit enter, and your PC will put itself to bed.

Lesser-known, but still worthwhile commands

Not all of the Command Prompt commands are ones you’ll need to use regularly, but that doesn’t mean there aren’t some handy functions among the less common ones. These are some of our favorites that often fly under the radar.

Ipconfig /flushdns — This is an extension of the IPConfig command, and it’s useful when you’re running into bizarre network or connection issues or change your DNS server. This one will often clear up any problems you have. This clears the Windows cache of DNS details, meaning that Windows will start using your preferred option instead.

Assoc — This command is used to view and change file associations, meaning the type of file, like .txt, .doc, etc. Typing “assoc [.ext]” — where ext is the file type in question — will tell you what it stands for, and “.txt” will tell you that it’s a text file. If you want to change that, you can type something like “assoc .log=txtfile” and all .log files will then be considered text files.

Note: This is a powerful command and should be used with caution. CommandWindows has a detailed guide on its more advanced functions.

Cipher — Cipher can be used to view and alter encryption information for your system’s files and folders. Depending on the additional parameters applied, you can have it encrypt files to protect them from prying eyes, create brand new encryption keys, and search for existing encrypted files. For the full list of parameters, Microsoft’s breakdown is comprehensive.

Finger  Finger is used to collect information about users on the computer or a connected remote computer. It’s often used to see what a specific user is doing or where they are, digitally speaking. It can be used with a specific computer or an IP address.

Deltree — Deltree is used to specify a particular file or directory path and delete it entirely, removing everything that used to be at that location. This can be a dangerous command for newcomers to use, so do so with caution, but it’s useful for users who want to get rid of data quickly.

Telnet — Telnet is not commonly used for accessing modern devices remotely, but some still require setup through the Terminal Network (Telnet) protocol. It’s not activated in Windows 10 by default, so to use it, you’ll need to turn it on. Start by going to the Windows 10 search bar at the bottom of the screen and typing in “Telnet.” Windows 10 is smart enough to suggest the right location. Select Turn Windows Features On or Off to open the window.

Scroll down until you find Telnet Client. Things are more or less in alphabetical order, which can help you find it. When you see it, make sure the box beside it is checked, then select OK. Windows will search for the necessary files and enable the software, then let you know you need to reboot to complete the changes. Do this and start back up!

Once enabled, Telnet can let you access remote devices or servers, though bear in mind it is completely unencrypted (a hacker’s dream). Commands will be very situation-specific but will look something like “telnet DigitalTrends.com 80,” which would have you attempt to connect to DigitalTrends.com on the 80 port. It won’t work, but that’s what a typical command might look like.

& — This command will let you run two commands at once. All you need do is put “&” between them, and both will execute at the same time.

| clip — Putting this command after your original command will copy the output directly to your clipboard. Say you want to copy down your IPConfig information — all you’d need to input is “ipconfig | clip” and the results will be added to your clipboard, so you can paste them anywhere you like.

You can also copy and paste in a similar manner to the main Windows interface.

nslookup — Want to find the IP address of any website? This command will do it for you. Simply type “nslookup” followed by the URL in question, and the Command Prompt will spit out an IP address.

A few additional tricks

Although the above commands are the most useful when using the Command Prompt, there’s more you can do. In learning how to use the Command Prompt, it’s good to also take note of these handy tricks.

Function keys — Although not so commonly used in modern software, the Function (F) keys can do quite a lot in a Command Prompt setting:

  • F1 lets you paste in your last command, character by character.
  • F2 pastes the last command only to a specified character.
  • F3 pastes it entirely.
  • F4 deletes a command up to a specified character.
  • F5 pastes the last used command without cycling.
  • F6 Pastes “^Z”.
  • F7 gives you a list of previously-used commands.
  • F8 pastes cyclable used commands.
  • F9 lets you paste a command from the list of recently used ones.

Driverquery — Although this is a command, it’s not likely to be one that many use. However, should you ever wish to see a comprehensive list of all of the drivers currently operating on your PC, typing “driverquery” into the Command Prompt is a great way to do it.

Change CMD color – You can get creative here if you want. If you’re not a fan of the classic white text on the black background, you can change the Command Prompt’s color scheme with a few clicks. Click on the window’s border, and a Properties menu will appear. Select the Colors tab and change the colors to whatever you want.

Compare files — You can conveniently compare a list of differences between similar versions of a file using a simple shortcut through CMD’s Compare File feature. To give it a try, type “FC,” the two filename locations, and the drive letter. It could look like this: “fc C:UsersTestDesktoptest.txt C:UsersTestDesktoptest2.txt”.

Watch Star Wars — That’s right – sing your own personal Command Prompt, you can watch the original Star Wars Episode IV: A New Hope (which, admittedly, is not everyone’s favorite). The movie is in ASCII graphics, but you can find the whole thing with the correct command trick. First, follow our guide’s instructions to enable Telnet. Then, type “telnet towel.blinkenlights.nl” and enjoy watching A New Hope in ASCII format.

Today’s tech news, curated and condensed for your inbox



Check your inbox!

Please provide a valid email address to continue.

This email address is currently on file. If you are not receiving newsletters, please check your spam folder.

Sorry, an error occurred during subscription. Please try again later.

Editors’ Recommendations

  • Experts fear ChatGPT will soon be used in devastating cyberattacks

  • This huge password manager exploit may never get fixed

  • Wi-Fi not working? Here’s how to fix the most common problems

  • The best web browsers for 2023

  • Best Microsoft Office deals for January 2023





Getting started

Windows, MacOS and Linux have command line interfaces. Windows’ default command line is the command prompt. The command prompt allows users to use their computer without pointing and clicking with a mouse.

The command prompt is a black screen where users type commands to use their computer. The same tasks that can be done by pointing and clicking with a mouse can also be done with the command prompt. The difference is that many tasks such as creating folders and deleting files can be done faster in the command prompt.

Also, it allows users to configure their computer and run programs that they otherwise could not do by pointing and clicking.

Opening the Command Prompt

To access the command prompt, click the windows start menu on the Desktop tool bar (you can also press the windows button on your keyboard) and type cmd and hit enter. The command prompt will appear, it will display some text like to following below:

C:UsersYourUserName>

Navigating Directories (Moving through folders)

C:UsersYourUserName is called your current working directory (directory is another way to say folder). It is like a street address that tells you where you are on your computer.

The current working directory can be a guide as you navigate through your computer. On the right of the > we can type cd, which stands for Change Directory, and the name of a directory that you want to navigate to. In this case we will type Documents. Enter cd Documents and your current working directory should look like the following:

C:UsersYourUserNameDocuments>

To go back one directory type and enter cd... Your current working directory should return to this:

C:UsersYourUserName>

With the cd and cd .. commands you can move back and forth through directories. This might seem very basic at first but as you learn more commands the command prompt will become a very useful and efficient tool.

Here is a list of common commands:

Screen-Shot-2020-03-18-at-3.25.08-PM

Usage Examples:

Making a Directory

mkdir name_of_the_directory_you_want_to_make

Getting Info on a Command

your_command /?

Deleting a File and Contents

rm /s name_of_directory_you_want_to_delete

Useful tips:

  • The command Ipconfig shows your computer’s ip address
  • If you type part of a directory’s name and hit the tab key the command prompt will autocomplete it and if you hit the tab key repeatedly it will cycle through directories that start with the same letter
  • You can use other shells or tools such as git bash or cmder to add more commands and functionality to your command prompt
  • Some tasks require you to run the command prompt as an administrator you clicking the windows button and typing cmd admin and hit the enter key
  • If you know the path to a file or directory can type cd PATH_TO_YOUR_DIRECTORY instead of changing directories several times to get to a directory or file
  • When you hit the up arrow key your previously entered command will appear and if you hit it repeatedly it will cycle through all of your previously entered commands

Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started

A lot of Windows users have never touched the Command Prompt. With today’s streamlined operating systems, it’s easy to use a computer without ever worrying about entering old-school text commands in the command line.

However, it’s a good idea to become familiar with command line basics in Windows. It helps you appreciate the OS more and can come in handy for some tasks. Here’s a beginner’s guide to the Windows Command Prompt for those who aren’t yet familiar.

What Is the Command Prompt?

The Command Prompt, officially called the Windows Command Processor and often abbreviated to CMD, is the command line interface for Windows operating systems. A command line interface is a way of interacting with a computer directly using text commands.

These hearken back to the early days of computers, when you had to type commands into a terminal to execute processes on the machine. Early PC operating systems, like MS-DOS, operated exclusively through command-line interfaces. There were no mouse cursor, window management, or similar graphical user interface (GUI) elements we take for granted today.

Another term you should know is the word «shell,» which is used to describe a program that allows the user to give commands to the computer. So a command line interface, as well as a GUI, are both shells.

Early versions of Windows, like Windows 3.1, effectively ran as a visual interface on top of DOS. Later versions, including Windows 95 through Windows ME, also included MS-DOS integration. These allowed you to run commands through the MS-DOS Prompt, as the Command Prompt was called at the time.

Starting with Windows XP, Windows broke away from MS-DOS. However, in modern versions of Windows, you can still use the Command Prompt to interface with your computer directly instead of clicking through various menus. The Command Prompt can also run batch files; these make automating tasks easy.

Power users prefer the Command Prompt for some tasks, as you can take actions with a few simple keystrokes that would require dozens of clicks in the GUI.

How to Open the Command Prompt in Windows 10 and Windows 11

There are a few ways to open the Command Prompt in Windows. Below are the most convenient:

  1. Type «command prompt» into the Start menu to search for it. You can also type «cmd» (the short name of the executable that runs the Command Prompt) if you prefer.
  2. Press Win + R to open the Run box, then type «cmd» and hit Enter to open it.
  3. Press Win + X (or right-click the Start button) and choose Command Prompt from the menu.
    1. Depending on your Windows settings, this may show Windows PowerShell or Windows Terminal instead. The new Windows Terminal and PowerShell are both more powerful than the Command Prompt, but are backward-compatible with all CMD commands.

Windows Open CMD Prompt

Any of these will open the Command Prompt with regular permissions. A lot of useful commands require you to have administrator permissions, which will fail with a regular CMD window.

To run the Command Prompt as an admin, hold Ctrl + Shift when you launch either of the first two options above. If you use the third option, pick Command Prompt (Admin) (or the corresponding option that appears for you) instead. This will require you to accept a UAC prompt, so you’ll need to be logged into an admin account or provide an admin password.

How to Use the Windows Command Prompt: Basics

When you open a Command Prompt window, you’ll see some basic info about your current Windows version. Below this, you’ll see a line like the below:

C:Users[Username]>

This is your current location. Any commands you run that rely on location (such as deleting files) will take place in this folder. Other CMD commands are more general and don’t rely on you being in a specific location.

It’s important to know that when working in the Command Prompt, you must type commands exactly as the system expects. Since you’re issuing commands directly to your computer, it won’t understand if you type something wrong.

If you type a command that your computer doesn’t recognize, you’ll see a message that says ‘[Command]’ is not recognized… and Windows won’t do anything.

Command Prompt Command Not Recognized

This isn’t a problem; what’s more of a risk is accidentally typing the wrong command, or using a command in a way you didn’t intend. For example, when trying to delete one file, you might accidentally tell it to delete an entire folder instead.

The command line will run whatever you tell it, as long as it’s a valid option. So you should always double-check what you’re about to do before you fire it off, and don’t use an admin Command Prompt for general purposes.

Basic Command Prompt Commands for Beginners

There are lots of Command Prompt commands, and most of them aren’t intuitive for newcomers. Learning them takes some time, so it’s best to pick up a few at a time and slowly build your knowledge.

Let’s look at a handful of CMD commands that illustrate its use for a beginner. These are just a very small sampling of what the Command Prompt can do, however. When you’re ready to move on, have a look at more CMD commands you should know, as well as our cheat sheet of handy Windows commands.

Getting Help

CMD Help Example Commands

Typing help will list many common commands that you can use. These will get you started, so you don’t have to go looking for command names on your own.

If you’d like more specific information about how to use a certain command, type it followed by /?. This will give you more help, plus additional options for modifying how it works.

Listing and Changing Directories

Windows Directory Command Example

The dir command, which is short for directory, will list the contents of the folder that you’re currently in. As mentioned earlier, you can check this by looking at the folder that appears to the left of your current command.

To change your current location, use cd (short for change directory) followed by the folder you want to visit. Available folders are marked with <DIR> when you run the dir command.

So for example, to move to your Desktop folder from your default user folder, you would type cd Desktop. You can move up one folder by using the cd.. shortcut.

Creating and Deleting Files and Folders

Use mkdir [new folder name] (make directory) to create a new folder. For instance, mkdir Awesome Pics will make a folder called Awesome Pics.

Similarly, rmdir [folder name] (remove directory) will delete a folder, but only if it’s empty. To delete a file, use del [file name].

CMD Management

If there’s too much clutter on the Command Prompt’s screen, type cls to clear the contents and start fresh. And if there’s a command running that you want to cancel (maybe it’s taking too long), hit Ctrl + C to end it.

Networking Commands

Some of the most useful Command Prompt commands deal with networking. Commands like ping let you see if your computer can reach a remote destination and how long it takes. Meanwhile, ipconfig lets you see the network overview for your current connection.

Ping CMD Example

Learning about CMD commands for managing networks is thus a great use of the tool.

Commands for Troubleshooting

A common use for firing up the Command Prompt is to run one of several troubleshooting commands. CHKDSK lets you scan your storage drives for errors, while SFC allows Windows to detect and fix corrupt system files. For more, see our comparison of CHKDSK, SFC, and DISM.

Taking the Command Prompt to the Next Level

Now you’re familiar with the basics of the Command Prompt, even if you’ve never used it before. Some tasks, like managing files and folders, will probably feel clunky in the command line if you’re used to doing these with the GUI. But for other tasks, like checking your IP address, running a quick CMD command is much more convenient than clicking through a bunch of menus.

While most CMD commands are specific to the Windows environment, Windows 10 and later also allow you to run the Bash shell used by Linux, macOS, and many other OSes. This is worth learning about if you use multiple platforms.

This section provides an overview of what cmd is, and why a developer might want to use it.

It should also mention any large subjects within cmd, and link out to the related topics. Since the Documentation for cmd is new, you may need to create initial versions of those related topics.

Opening a Command Prompt

The command prompt comes pre-installed on all Windows NT, Windows CE, OS/2 and eComStation operating systems, and exists as cmd.exe, typically located in C:Windowssystem32cmd.exe

On Windows 7 the fastest ways to open the command prompt are:

  • Press enter image description here, type «cmd» and then press Enter.

  • Press enter image description here+R, type «cmd» then then press Enter.

It can also be opened by navigating to the executable and double-clicking on it.

In some cases you might need to run cmd with elevated permissions, in this case right click and select «Run as administrator». This can also be achieved by pressing Control+ Shift+Enter instead of Enter.

Navigating in cmd

One of the most common things you’ll need to do in the command prompt is navigate your file system. To do this, we’ll utilize the cd and dir keywords. Start by opening up a command prompt using one of the methods mentioned here. You most likely see something similar to what’s below, where UserName is your user.

C:UsersUserName>

Regardless of where in your file structure you are, if your system is like most, we can start with this command:

cd C:

This will change your current directory to the C: drive. Notice how the screen now looks like this

C:>

Next, run a dir so we can see anything in the C: drive

dir

This will show you a list of files and folders with some information about them, similar to this:

dir command

There’s lots of good info here, but for basic navigation, we just care about the right-most column. Notice how we have a Users folder. That means we can run this

cd Users

Now if you run dir again, you’ll see all the files and folders in your C:Users directory. Now, we didn’t find what we wanted here, so let’s go back to the parent folder. Rather than type the path to it, we can use .. to go up one folder like so

cd ..

Now we are back in C:. If you want to go up multiple folders at once, you can put a backslash and another set of periods like so: cd ...., but we only needed one folder.

Now we want to look in that Program Files folder. To avoid confusing the system, it’s a good idea to put quotes around the directories, especially when there are spaces in the name. So this time, we’ll use this command

C:>cd "Program Files"

Now you are in C:Program Files> and a dir command now will tell you anything that’s in here.

So, say we get tired of wandering around to find the folder and looked up exactly where we were needing to go. Turns out it’s C:WindowsLogs Rather than do a .. to Windows to Logs, we can just put the full path like so:

cd "C:WindowsLogs"

And that’s the basics of navigating the command prompt. You can now move through all your folders so you can run your other commands in the proper places.

Commands in CMD

The available commands will be displayed, including a brief description, in tabular format.
In Windows 10 the following commands are listed:

Command Description
ASSOC Displays or modifies file extension associations.
ATTRIB Displays or changes file attributes.
BREAK Sets or clears extended CTRL+C checking.
BCDEDIT Sets properties in boot database to control boot loading.
CACLS Displays or modifies access control lists (ACLs) of files.
CALL Calls one batch program from another.
CD Displays the name of or changes the current directory.
CHCP Displays or sets the active code page number.
CHDIR Displays the name of or changes the current directory.
CHKDSK Checks a disk and displays a status report.
CHKNTFS Displays or modifies the checking of disk at boot time.
CLS Clears the screen.
CMD Starts a new instance of the Windows command interpreter.
COLOR Sets the default console foreground and background colors.
COMP Compares the contents of two files or sets of files.
COMPACT Displays or alters the compression of files on NTFS partitions.
CONVERT Converts FAT volumes to NTFS. You cannot convert the
current drive.
COPY Copies one or more files to another location.
DATE Displays or sets the date.
DEL Deletes one or more files.
DIR Displays a list of files and subdirectories in a directory.
DISKPART Displays or configures Disk Partition properties.
DOSKEY Edits command lines, recalls Windows commands, and
creates macros.
DRIVERQUERY Displays current device driver status and properties.
ECHO Displays messages, or turns command echoing on or off.
ENDLOCAL Ends localization of environment changes in a batch file.
ERASE Deletes one or more files.
EXIT Quits the CMD.EXE program (command interpreter).
FC Compares two files or sets of files, and displays the
differences between them.
FIND Searches for a text string in a file or files.
FINDSTR Searches for strings in files.
FOR Runs a specified command for each file in a set of files.
FORMAT Formats a disk for use with Windows.
FSUTIL Displays or configures the file system properties.
FTYPE Displays or modifies file types used in file extension
associations.
GOTO Directs the Windows command interpreter to a labeled line in
a batch program.
GPRESULT Displays Group Policy information for machine or user.
GRAFTABL Enables Windows to display an extended character set in
graphics mode.
HELP Provides Help information for Windows commands.
ICACLS Display, modify, backup, or restore ACLs for files and
directories.
IF Performs conditional processing in batch programs.
LABEL Creates, changes, or deletes the volume label of a disk.
MD Creates a directory.
MKDIR Creates a directory.
MKLINK Creates Symbolic Links and Hard Links
MODE Configures a system device.
MORE Displays output one screen at a time.
MOVE Moves one or more files from one directory to another
directory.
OPENFILES Displays files opened by remote users for a file share.
PATH Displays or sets a search path for executable files.
PAUSE Suspends processing of a batch file and displays a message.
POPD Restores the previous value of the current directory saved by
PUSHD.
PRINT Prints a text file.
PROMPT Changes the Windows command prompt.
PUSHD Saves the current directory then changes it.
RD Removes a directory.
RECOVER Recovers readable information from a bad or defective disk.
REM Records comments (remarks) in batch files or CONFIG.SYS.
REN Renames a file or files.
RENAME Renames a file or files.
REPLACE Replaces files.
RMDIR Removes a directory.
ROBOCOPY Advanced utility to copy files and directory trees
SET Displays, sets, or removes Windows environment variables.
SETLOCAL Begins localization of environment changes in a batch file.
SC Displays or configures services (background processes).
SCHTASKS Schedules commands and programs to run on a computer.
SHIFT Shifts the position of replaceable parameters in batch files.
SHUTDOWN Allows proper local or remote shutdown of machine.
SORT Sorts input.
START Starts a separate window to run a specified program or command.
SUBST Associates a path with a drive letter.
SYSTEMINFO Displays machine specific properties and configuration.
TASKLIST Displays all currently running tasks including services.
TASKKILL Kill or stop a running process or application.
TIME Displays or sets the system time.
TITLE Sets the window title for a CMD.EXE session.
TREE Graphically displays the directory structure of a drive or
path.
TYPE Displays the contents of a text file.
VER Displays the Windows version.
VERIFY Tells Windows whether to verify that your files are written
correctly to a disk.
VOL Displays a disk volume label and serial number.
XCOPY Copies files and directory trees.
WMIC Displays WMI information inside interactive command shell.

To get more insight about a specific command use the /? option, e.g. the tree command gives:

tree /?

Graphically displays the folder structure of a drive or path.

TREE [drive:][path] [/F] [/A]
 
   /F   Display the names of the files in each folder.
   /A   Use ASCII instead of extended characters.

Features

Microsoft Command Prompt is a command-line interpreter (CLI) for the Windows operating systems.

A CLI is program intended primarily to read operating system instructions typed on a keyboard by the user.
It is therefore addressed also as a command-line interface, to contrast it with graphical interfaces.

As these interfaces (whether textual or graphical) shield the user from directly accessing to the operating system kernel, they are also said shells.

Given the name of the Command Prompt executable file, cmd.exe, the Command Prompt is friendly named cmd.
Given its OS piloting role, it is also said the console.

Like other shells, cmd can read batch of instructions from a file. In this case the cmd shell acts as a language interpreter and the file content can be regarded as an actual program. When executing these batch programs, there is no intermediate compilation phase. They are typically read, interpreted and executed line by line. Since there is no compilation, there is no production of a separated executable file. For this reason the programs are denoted batch scripts or shell scripts.

Note that the instructions entered interactively might have a slightly different syntax from those submitted as a script, but the general principle is that what can be entered from the command line can be also put in a file for later reuse.

Hello World

Command Prompt batch scripts have extension .cmd or .bat, the latter for compatibility reasons.

To create a hello-word-script, you first need a place where to type it.
For simple scripts, also the Windows Notepad will do. If you are serious about shell scripting, you need more effective tools. There are anyway several free alternatives, such as Notepad++.

In your designated editor type:

echo Hello World
pause

Save it as hello.cmd

If you are using «Notepad» as an editor, you should pay much attention to the saved name, as Notepad tends to add always a .txt extension to your files, which means that the actual name of your file might be hello.cmd.txt. To avoid this, in the save dialog box:

  1. In the File name field enter the name in double quotes, e.g. "hello.cmd"
  2. In the Save as type field select All Files, instead of the default Text Document option.

If the file has been saved properly, its icon should be similar to (Windows Vista):

cmd icon

You may also consider to disable the option «Hide extension for known file types» in File Explorer folder view options. In this case, file names are always displayed with their extensions.

To execute hello.cmd there are two possibilities. If you are using the Windows graphical shell, just double click on its icon.

If you want to use the Command Prompt itself, you must first identify the directory where you saved hello.cmd.
In this regard, if you open File Explorer with +E. In the windows listing files, you normally read the name of the directory path containing them. You can therefore identify the directory of hello.cmd. Windows directory names tend to be quite long and typing them is error prone. It is better if you select and copy the directory path in the clipboard for later pasting.

Start the Command Prompt. You read a line similar to this.

Microsoft Windows [Version ...]
(c) ... Microsoft Corporation. All rights reserved.
 
C:Users...>

The version/year of Windows of course depends on yours.
In the the final line, before >, you read the path of the directory which is current. You should make current the directory where your script is. For this reason enter the change directory command cd, using a line similar to the following:

cd <dirpath>

Instead of <dirpath>, paste the name of the directory you previously copied.
To paste the directory path, in Windows 10, you just need to type CtrlC, as you would in an editor.
For older systems you should be able to do this by right clicking in the cmd window.
After entering the command, note that current path, before >, changes accordingly.

You can now run your hello script by simply entering:

hello

Comments

The script prints an output similar to:

C:Users...>echo Hello World
Hello World

C:Users...>pause
Press any key to continue . . .

The lines hosting the symbol > restate the script instructions as if you had entered interactively.
This can be disabled writing:

@echo off

as the first line of your script.
This might reduce the clutter, but you have less hints on what is going on, with respect to those script commands that do not give visible outputs.

The last command, pause, prompts you to hit any key. When you do, you exit hello.
If you run hello from the console, you don’t really need it, because, when hello terminates its execution, cmd.exe remains open and you can to read hello output.
When double-clicking in Explorer, you start cmd.exe for the time necessary to execute hello. When hello terminates, cmd.exe does the same and you have no possibility to read hello output.
pause command prevents hellofrom exiting until you hit a key, which gives also the possibility to read the output.

Finally, despite the name of the script is hello.cmd, it is not necessary to type the whole name, its hello stem is sufficient. This mechanism works for executables too, with extension .exe. What if there is a script hello.cmd and an executable hello.exe in the same directory? The former has priority in the Command Prompt, so hello.cmd will be executed.

Понравилась статья? Поделить с друзьями:

Вот еще несколько интересных статей:

  • How to use bash in windows
  • How to use aircrack on windows
  • How to upgrade windows 10 version
  • How to upgrade to windows 10 professional
  • How to upgrade to windows 10 from windows vista

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии