Learn 50 CMD Commands on Microsoft Windows

Are you a Windows PC user? Are you looking for a collection of Command Prompt (CMD) commands that can make it easier to operate the device?

Although currently all the cool features in the Windows operating system can be used directly in a beautiful GUI (Graphical User Interface) mode , in reality CMD still cannot be abandoned by its users.

Whether it’s to help in the use of basic features, to doing things that are very technical. In fact, not a few of them are looking for CMD commands to hack websites.

Well, talking about the Command Prompt command, in this article Matob will give you a collection of CMD commands and their functions that you can try. Come on, take a look!

What is a CMD Command?

Command Prompt or CMD is a command line interpreter (CLI) application that exists in the Windows operating system. The commands in CMD serve to perform various operations on your computer.

Actually, these commands have been around since the days of MS-DOS. However, ordinary Windows users have rarely used the CMD command because the same function is now more easily accessible through the menu.

However, the CMD command gives you more control over the operation of your computer. The variety is a lot. However, don’t worry. You can use the list in this article as a cheat sheet!

How to Open CMD / Command Prompt

Here’s an easy and quick way to open CMD on your computer via a shortcut (Windows shortcut) :

  1. Press Windows key (window image) + R on your keyboard
  2. Type CMD , then press Enter
    open cmd using run program
  3. Congratulations! The command prompt is open. Easy and fast, isn’t it?

Complete List of CMD Commands and Their Functions

Before entering into this list of CMD commands, you need to know that not all commands can be used in all versions of Windows. To know which are the basic CMD commands that you can use, see the explanation below.

1. append

Supported in: all versions except Windows 10

The append command allows you to open files that are in another directory, even when you are not in that directory. An example of its use is as below:

append c:\docs;c:\letters edit myfile.txt

The goal with this command is to open and edit a file called myfile.txt. If the file is not in the directory you are currently opening, the command will look for it in the c:\docs and c:\letters directories.

If you want to add more than one search directory, use a semicolon (;) to separate each directory.

2. arp

Supported in: all versions of Windows

As the name implies, the arp command is used to manage ARP or the address resolution protocol . ARP itself is part of the IP ( internet protocol ) that directs a 32-bit IP address to a MAC ( medium access control ) address.

Here is an example of using the arp command. Let’s say your IP address is 220.0.0.160. If you want to replace it, just run the following command:

arp -s 220.0.0.161 00-50-04-62-F7-23

With this command, your IP address will be replaced with 220.0.0.161.

3. assoc

Supported in: all versions after Windows 98

The assoc command is used to check the file extension associated with a file type. For example, say you want to display a description of the .txt extension. For that, you need to run the following command.

assoc .txt

After you enter the command, it will display the words .txt=txtfile, which means .txt is an extension for text files.

In addition, the assoc command can also be used to change or remove the association of a file extension with a file type. Here is an example of using it to delete:

assoc .txt=

If you want to use the above command, don’t forget to add a space after the equal sign (=).

4. at

Supported on: Windows 2000 and XP

The at command is used to automate various other commands at specified times. Although it’s only supported on three older versions of Windows, at actually can also be used on Vista and 7 even though the status is deprecated (no longer getting updates or support).

Starting in Windows 8, at has been replaced with schtasks which has a similar function. This command will also be discussed later.

The at command itself has several uses. If you just type at, the Command Prompt will display a list of automated commands.

Note that each of these commands is represented by an ID number. This number is useful when you want to remove the automation of an already registered command.

For example, the command below will remove the command automation with ID 1:

at 1 /delete

If you want to delete everything, you can type the following command:

at /delete /yes

Now, let’s try to automate the command with the following example:

at 6:50PM /every:5,10,15,20,25 "c:\winnt\task.bat"

In this example, your computer will run the task.bat file automatically at 6:50 p.m. every 5th, 10th, 15th, 20th, and 25th. As a reminder, you can only use the date to specify the day the automation will run.

If /interactive is added after runtime as in the example below, you’ll be able to interact with the file when it’s run.

at 6:50PM /interactive /every:5,10,15,20,25 c:\winnt\beep.bat

5. attrib

Supported in: all versions of Windows

Have you ever come across a file you don’t want, but you can’t delete? Perhaps the file attribute is set to read-only .

To change its attributes, the common way is to right-click on the file, then open Properties. At the bottom of the Properties window you will find a checkbox to turn this attribute off or on.

attribute-file

However, you can also do this with the attrib CMD command. For example, as shown below:

attrib -R example.txt

In that example, -R implies removing the read-only attribute from the file in question. If you want to add an attribute, then the minus sign (-) is replaced with a plus sign (+).

In addition to R, there are three other attributes you can set with the attrib command:

  • H = hidden, to hide the file and vice versa
  • S = system, indicates that a file is used for operating system requirements
  • A = archive, indicates that a file has never been backed up

6. bcdedit

Supported in: all versions after Windows XP

bcdedit is a command that allows you to do three things: manage the boot configuration data store, save the configuration parameters, and set the operating system boot .

The bcdedit command format is actually simple. Here’s an example:

bcdedit /command <argument>

/command is a sub-command that can be used with bcdedit, while <argument> is the name of the file or directory that is the target of this command.

Well, what makes bcdedit quite complicated is the number of sub-commands it contains. Below are some of the sub-commands and their functions:

  • /createstore — create a new boot configuration data store
  • /create — creates a new entry in a boot configuration data store
  • /deletevalue — removes an element from boot entry
  • /bootdebug — enable the boot debugger in a boot entry or vice versa

To see the full list of bcdedit sub-commands you can run the following command:

bcdedit /?

If you want to know the use of a sub-command, you just add its name after the command, like this:

bcdedit /? createstore

7. bootsect

Supported in: all versions after Windows 98

The bootsect command is used to update the master boot code in the hard drive partition. Thus, you can change the boot sequence manager type from NTLDR to BOOTMGR and vice versa.

For example, you need the command below to change the master boot code for partition: E on your computer:

bootsect /nt52 E:

8. break

Supported in: all versions of Windows

Depending on the setting, the key combination ctrl + C can be used to stop an MS-DOS process. For example a batch file .

Well, break is the command used to define that setting. Examples are as follows:

break off

If you run the command, the key combination ctrl + C cannot be used to stop the MS-DOS process. If you just want to check this setting, just type “break”.

9. cacls

Supported in: all versions after Windows 98

The cacls command is used to check or modify the access control list (ACL) of a file. ACL itself is a list that contains access control entries (ACE). This list is used to determine access to files owned by a user on a computer.

The cacls syntax is quite simple, as you can see below:

cacls [file name] [sub-command]

There are several sub-commands cacls that can be used, namely:

  • /T — replaces the ACL of specified files in a directory and all sub-directories in it
  • /E — like the previous sub-command, but serves to change the contents of the ACL
  • /G user:perm — grant permissions to a user
  • /R user — remove permissions from a user
  • /P user:perm — change the permissions of a user
  • /D user — remove file access from a user

To populate a perm, there are four codes you can use:

  • n — none (no access)
  • r – read (opens a file)
  • w — write (mengubah file)
  • f — full control (full access)

For example, the code below is run if you want to grant full access to the user named user1 for the myfile.txt file:

cacls myfile.txt /e /g user1:f

If you just want to know the ACL of a file, you don’t need to add a sub-command.

10. call

Supported in: all versions of Windows

The CMD call command is used to run a batch file inside another. For example, the command below will run the second.bat file inside the running batch file :

call second.bat

11. change

Supported in: all versions after Windows XP

As the name suggests, the change command is used to change the remote desktop (RD) session host server settings for logon status , COM port mapping , and installation mode. The syntax for each of these uses is different. Therefore, we will discuss them one by one.

change logon

The change logon command sets the logon status in the client session . For example, you can allow logon by changing its status to enabled , as below:

change logon /enable

Instead, if you want to prevent logonings , use the following command:

change logon /disable

To simply check the status, run this command:

change logon /query

change port

You will need the change port command when you want to change the COM port mapping . For example, running the following command will switch COM12 to COM1:

change port com12=com1

change user

As we mentioned earlier, change user is used to change the installation mode of the RD session host server . An example of its use is as follows:

change user /execute

The above command allows mapping the .ini file to the main directory. However, this means that you cannot install any application on the RD session host server . To allow it, use this command:

change user /install

12. chdir

Supported in: all versions of Windows

Want to use CMD commands for directory navigation? Can! You just use chdir. With this command, you can return to the previously opened directory with a command like below:

chdir..

If the command is executed, the effect will be like when you click the back button in File Explorer.

In addition, chdir can also be used to return to the main directory. Examples are as follows:

chdir\

With that command, from the C: \ Windows \ COMMAND> directory you can jump to C: \ in an instant.

Interestingly, you can open a directory by simply typing its name. For example:

chdir\windows\system32

By executing that command, the system32 directory is directly accessed.

As a side note, you can also replace chdir with cd. Both commands have the same function and syntax.

13. chkdsk

Supported in: all versions of Windows

Is your laptop or computer slow? As a first check step, you can run the chkdsk command. This command serves to check the status of your hard drive.

In addition, chkdsk can also be used to try to repair hard drive errors due to bad sectors . Just run the following command:

chkdsk d: /r

14. chkntfs

Supported in: all versions after Windows 98

The chkntfs function is related to chkdsk. With it, you can instruct the computer to check all the hard drive partitions and run chkdsk on the partitions that are considered problematic. The command is as follows:

chkntfs /d

15. cipher

Supported in: all versions after Windows 98

The cipher command is closely related to the encryption of files and folders on NTFS type hard drives . There are three main functions that you can take advantage of this CMD command.

First, you can check the encryption status of a file or folder with the command below:

cipher /c myfile.txt

Second, you can encrypt a file or folder by replacing /c with /e, as in the following example:

cipher /e myfile.txt

Third, the cipher command allows you to turn off file or folder encryption with the /d sub-command:

cipher /d myfile.txt

16. clip

Supported in: all versions after Windows XP

The clip command is used when you want to copy the output from a CLI to the clipboard for one reason or another. The syntax is also very simple; just type clip in the Command Prompt and write the name and file extension you want to copy run. Examples like this:

clip readme.txt

17. cls

Supported in: all versions of Windows

For those of you who use the Command Prompt for various purposes, the cls command is very useful. By running this command, you can delete all text in CMD, both what you type and the output.

Like clip, you just type cls to use this command.

also read : how to create folder using cmd

18. cmdkey

Supported in: all versions after Windows XP

cmdkey is used to create, delete, or view usernames and passwords used to log in to a computer. This command is useful if you are the admin user of the computer.

The use is simple. If you want to see a list of usernames and passwords belonging to computer users, type:

cmdkey /list

Now let’s try to register a username and password with the following command:

cmdkey /add:server01 /user:userbaru /pass:pf90

With that, you have created access for a user named new user with password pf90 in order to enter server01.

If you want to delete it, just use this command:

cmdkey /delete:userbaru

You can also clear the list of usernames and passwords on a server:

cmdkey /delete:server01

19. color

Supported in: all versions after Windows 2000

Tired of the black and white appearance of Command Prompt? You can change the color with the color command. The syntax is like this:

color <b><f>

<b> determines the background color, while <f> determines the text color. To determine the color, you use the numbers 0 to 9. However, you cannot choose the same color. Here are the colors you can choose from and the numbers that represent them:

  • 0 black
  • 1 biru
  • 2 green
  • 3 aqua
  • 4 red
  • 5 purple
  • 6 yellow
  • 7 white
  • 8 gray
  • 9 light blue

In addition, there are six more colors to choose from. However, all six are represented by letters. Here’s the list:

  • a light green
  • b aqua young
  • c pink
  • d ungu time
  • e light yellow
  • f bright white

For example, with the following command the Command Prompt background will turn gray with red text:

color 84

If you want to return the Command Prompt to its original color, just type color without any additions.

20. comp

Supported in: all versions after Windows 98

The comp command is used to compare two files. Usually, this CMD command is used when you want to check the code of the two files. Examples are as follows:

comp file1.txt file2.txt /n=10 /a

With the above command, you compare file1.txt and file2.txt.

/n specifies the number of lines of code to be checked with the comp command. In that example we compared the first ten lines of code, but you can change it however you want.

/a is used to display the output of the comp command in the ASCII character set. The results are as follows:

Compare error at LINE 5
file1 = i
file2 = o
Compare error at LINE 5
file1 = v
file2 = u
Compare error at LINE 5
file1 = e
file2 = r
Compare error at LINE 6
file1 = s
file2 = f
Compare error at LINE 6
file1 = x
file2 = v
Compare error at LINE 6
file1 =
file2 = e
Compare error at LINE 7
file1 =
file2 =
Compare error at LINE 7
file1 =
file2 =
Compare error at LINE 8
file1 =
file2 = s
File1 only has 7 lines

21. compact

Supported in: all versions after Windows 2000

Earlier you have studied file encryption with ciphers. Now we will discuss the command used to compress files, namely compact. However, you need to remember that this command can only work on NTFS type partitions.

For starters, perhaps you want to check the compression status of each file in a directory. The following sample command allows you to check all files in the currently accessed directory:

compact

If there is a file you want to compress, the command is something like this:

compact file.txt /c

For the opposite, you just replace /c with /u. For the record, compressing or decompressing a file will mark the directory in which it is stored. Once marked, all files stored in that directory will be compressed or decompressed.

22. convert

Supported in: all versions after Windows 98

As the name implies, the convert command is used when you want to convert a FAT partition to NTFS. For example like the following example:

convert d: /fs:ntfs

23. copy

Supported in: all versions of Windows

The use of the copy command is the same as its name, which is to copy a file to a different location. To understand its use, consider the example below:

copy myfile.txt d:\

The command prompts the copying of the file myfile.txt which is in the directory you are currently accessing to the D: directory.

You can also use the copy command to copy all files of the same type. To do this, use an asterisk (*) as in this example:

copy *.txt d:\

In fact, the copy command can also be used to copy all files in one directory, as in the following example:

copy *.* f:\

Of course, this command is useful if you want to copy files to a removable drive such as a flash drive.

also read : how to delete file and folder using cmd

24. date

Supported in: all versions of Windows

The date command is used to view the date or change it. The syntax is very simple. After typing “date”, the Command Prompt will display today’s date and a question to change the date. If you don’t want to change it, all you have to do is press the enter key on the keyboard.

25. defrag

Supported in: all versions of Windows

If you are diligent in doing hard drive optimization , perhaps you are already familiar with the Disk Defragmentation feature. You can also do this in the Command Prompt with the CMD defrag command.

To simply do defragmentation , you just need to run this command:

defrag c:

If you want to analyze the partition first, add /a as in the following example:

defrag c: /a
In addition, you can also defragment all partitions:
defrag /c

26. of

Supported in: all versions of Windows

You can use Command Prompt to delete files with the command del. Let’s look at the following examples to understand their usage.

To delete a file from the currently accessed directory, use the following command:

del myfile.txt

Files deleted with this command will go to the Recycle Bin as usual. However, you may want to display a confirmation question before the selected file is actually deleted. If so, add /p as in the example below:

del myfile.txt /p

Do you have to access the directory of the file you want to delete? Of course not. You can do it from another directory with this command:

del c:\windows\test.tmp

You can even delete entire files in a directory with the following command:

del c:\windows\temp\*.*

Interestingly, the del command gives you an ability you can’t have using File Explorer, namely deleting files with the read only attribute . You do this by adding /f after the filename:

del myfile.txt /f

As a reminder, you can replace the del command with delete or erase because all three have the same function.

27. deltree

Supported on: Windows 95, 98, and ME

If the files deleted with the del, delete, and erase commands go into the Recycle Bin, it is different with the deltree command. This command serves to delete files permanently. Not only that, deltree can also delete all sub-directories in a directory.

An example of its use is as follows:

deltree d:\pictures

With the above command, the directory named pictures on partition D: and all of its sub-directories will be permanently deleted.

28. you

Supported in: all versions of Windows

The dir command is useful for viewing a list of files and sub-directories in a directory. In addition, this command is also used to display various information about your hard drive , including:

  • Serial number
  • Number of files on the hard drive
  • Total file size
  • Remaining space on hard drive

Let’s discuss the syntax for each function. If you just want to display a list of files and sub-directories in the currently accessed directory, type “dir”.

This command can be made more flexible to show only files with certain extensions, as in the following example:

dir *.txt *.doc

With the above command, Command Prompt will only show .txt and .doc files in your directory.

The use of the dir command is also inseparable from the file attribute. The following is a list of attributes and their symbols in the dir command syntax:

  • d – directory
  • r — file read only
  • h — hidden files ( hidden )
  • a — files that have not been archived or backed up
  • s — file sistem
  • i — unindexed files

Examples of its use are as follows:

dir / a: r

With the above command, only files with the read only attribute will be shown .

29. diskpart

Supported in: all versions after Windows 98

The diskpart command is used to manage hard drive partitions on your computer or laptop. With it, you can create new partitions, delete them, and display a list of existing partitions.

To use it, type “diskpart” first. After that, type “list disk” to display a list of hard drives on the computer. Below is an example of the output:

 Disk ### Status Size Free Dyn Gpt
 -------- ------------- ------- ------- --- ---
 Disk 0 Online 476 GB 449 MB
 Disk 1 Online 2047 GB 0 B
 Disk 2 No Media 0 B 0 B
 Disk 3 No Media 0 B 0 B
 Disk 4 No Media 0 B 0 B
 Disk 5 No Media 0 B 0 B

Let’s say you want to manage partitions on disk 0. To select it, type “select disk 0”. Then type “list partition” to see a list of partitions in it. An example of the output is as below:

Partition ### Type Size Offset
 ------------- ---------------- ------- -------
 Partition 1 Primary 549 MB 1024 KB
 Partition 2 Primary 195 GB 550 MB
 Partition 0 Extended 269 GB 195 GB
 Partition 4 Logical 29 GB 195 GB
 Partition 5 Logical 29 GB 225 GB
 Partition 6 Logical 8 GB 254 GB
 Partition 7 Logical 202 GB 262 GB
 Partition 3 Recovery 502 MB 465 GB

Well, now you can choose the partition you want to manage. For example, type “select partition 1”. At this point, you can take advantage of the various sub-commands that diskpart supports. Here are some of them that are frequently used:

add

The add sub-command works to create a new partition that is similar to another partition that already exists on your computer. Examples of its use are as follows:

add disk=1

With this sub-command, a new partition with the same settings as partition number 1 will be created.

assign

If you use add disk, the new partition created does not have a letter. The assign sub-command is used to specify the letter. However, don’t forget to use the select partition command first to select the partition you want to assign letters to.

In the example below, the letter E: is assigned to the selected partition:

assign letter=e

delete

As the name implies, this sub-command is used to delete a partition. Here is an example of its use:

delete partition

detail

With the detail sub-command, you can view information about the selected partition. Type in “detail partition” and you will see output like the following:

Partition 1
Type : 07
Hidden: No
Active: Yes
Offset in Bytes: 1048576
 Volume ### Ltr Label Fs Type Size Status Info
 ---------- --- ----------- ----- ---------- ------- --------- --------
* Volume 0 System Rese NTFS Partition 549 MB Healthy System

29. driverquery

Supported in: all versions after Windows XP

Driverquery command is used to display a list of drivers that be installed on your computer or laptop. An example of the output is as follows:

Module Name Display Name Driver Type Link Date
============ ====================== ============= ======================
...
PptpMiniport WAN Miniport (PPTP) Kernel 7/15/2016 8:28:13 PM
Processor Processor Driver Kernel 7/15/2016 8:10:42 PM
Psched QoS Packet Scheduler Kernel 7/15/2016 8:25:21 PM
QWAVEdrv QWAVE driver Kernel 7/15/2016 8:28:46 PM
RasAcd Remote Access Auto Con Kernel 7/15/2016 8:29:11 PM
RasAgileVpn WAN Miniport (IKEv2) Kernel 7/15/2016 8:27:00 PM
Rasl2tp WAN Miniport (L2TP) Kernel 7/15/2016 8:27:35 PM
RasPppoe Remote Access PPPOE Dr Kernel 7/15/2016 8:28:21 PM
RasSstp WAN Miniport (SSTP) Kernel 7/15/2016 8:27:11 PM
...

30. edit

Supported in: all versions up to Windows 7 but not supported on 64-bit systems

Command Prompt actually has a built-in text editor tool. To access it, you just run the CMD edit command. For example, as shown below:

edit c:\myfile.txt

This command will open a file called myfile.txt. If the file does not exist, the tool will automatically create a new file with the name you specify.

31. exit

Supported in: all versions of Windows

The exit command is used to exit the Command Prompt or close the running batch script process . To run it, you just need to type “exit”.

32. expand

Supported in: all versions after Windows 98

Previously you have recognized the compact command used to compress files. Well, expand is the opposite. This command is used to decompress. The syntax is quite simple:

expand <source> <destination>

<source> is the location of the file you want to open, while <destination> is the directory where you want to put the contents of the file. An example of its use is as follows:

expand d:\i386\hal.dl_ c:\windows\system32\hall.dll

33. find

Supported in: all versions of Windows

The Command Prompt allows you to search for specific text in a file with the find command. The syntax is like this:

find [string] [drive\ file name]

For example, let’s say you want to find the text “REM” in the autoexec.bat file located on the C: drive . Then you need to run the following command:

find "REM" c:\autoexec.bat

Note that the find command will search for text that matches what you typed. Therefore, you need to pay attention to the use of capital letters.

For example, this command will not display the text “rem” in lowercase in your search results.

However, you can also ask the command to ignore the typeface. To do this, you just add /I before the text you’re looking for.

34. ipconfig

Supported in: all versions of Windows

ipconfig is a CMD command used to display information about specified network settings for your computer or laptop.

By typing “ipconfig” in the Command Prompt, you can already see the information, as in the following example:

Connection-specific DNS Suffix . : hsd1.ut.comcast.net.
IP Address. . . . . . . . . . . . : 192.168.201.245
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.201.1

However, you can also view the full information by adding “/all” at the end of the command. The result will be like this:

Host Name . . . . . . . . . : COMPUTERH1
DNS Servers . . . . . . . . : 123.45.67.8
111.111.111.1
111.111.111.1
Node type .. .. .. .. ..: Broadcast
NetBIOS Scope ID. . . . . . :
IP Routing Enabled. . . . . : No
WINS Proxy Enabled. . . . . : No
NetBIOS Resolution Uses DNS : No
0 Ethernet adapter :
Description . . . . . . . . : PPP Adapter.
Physical Address. . . . . . : 44-44-44-54-00-00
DHCP Enabled. . . . . . . . : Yes
IP Address. . . . . . . . . : 123.45.67.12
Subnet Mask . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . : 123.45.67.8
DHCP Server . . . . . . . . : 255.255.255.255
Primary WINS Server . . . . :
Secondary WINS Server . . . :
Lease Obtained. . . . . . . : 01 01 80 12:00:00 AM
Lease Expires . . . . . . . : 01 01 80 12:00:00 AM
1 Ethernet adapter :
Description . . . . . . . . : 3Com 3C90x Ethernet Adapter
Physical Address. . . . . . : 00-50-04-62-F7-23
DHCP Enabled. . . . . . . . : Yes
IP Address. . . . . . . . . : 111.111.111.108
Subnet Mask . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . : 111.111.111.1
DHCP Server . . . . . . . . : 111.111.111.1
Primary WINS Server . . . . :
Secondary WINS Server . . . :
Lease Obtained. . . . . . . : 11 16 00 12:12:44 AM
Lease Expires . . . . . . . :

Apart from displaying your network settings, the ipconfig command also has other uses when used with its sub-commands. Here are some commonly used sub-commands:

  • /release — removes DHCP and IP address settings for all network adapters in use. You can also type the adapter name to use ipconfig/release against only that adapter
  • /renew — Updates DHCP and IP address settings for all network adapters in use. Like the previous sub-command, you can also use ipconfig/renew on the selected adapter
  • /flushdns — clears the DNS cache stored on your computer. This needs to be done regularly so that you can still access the sites you usually visit

35. logoff

Supported in: all versions after Windows 98

As the name implies, the logoff command is used to log off from your computer. In the context of a local computer network, this CMD command can also be used to terminate a specific user session.

To run it, you just type “logoff”. If you are an administrator, you can terminate a user’s session by adding their computer ID, as in the following example:

logoff 12

36. move

Supported in: all versions of Windows

The move command allows you to move one or more files to another directory. In fact, you can use it to move one directory into another as well. The syntax is as follows:

move <file name> <destination>

An example looks like this:

move stats.doc c:\statistics

If you are not currently in the file directory, you will need to specify the partition letter and directory name:

move d:\docs\stats.doc c:\statistics

If you want to move more than one file, you must separate each one with a comma and a space:

move stats.doc, morestats.doc c:\statistics

So, to move a directory into another directory, you need to add double quotes at the beginning and end of the directory name:

move "direktori1" direktori2

37. msg

Supported in: all versions after Windows 2000

If you are on a local computer network, you can send messages to other users with the msg command. The syntax is like this:

msg <username> <message>

Below is an example if you send a message that says “Hello” to a user named “user01”:

msg user01 Halo

38. pause

Supported in: all versions of Windows

The pause command is used to stop a running batch file . When executed, the message “Press any key to continue” will appear on the screen. To continue the file process, you just press any key on the keyboard.

39. print

Supported in: all versions of Windows

Perhaps you didn’t know that you can print text files from the Command Prompt. To do this, you need to specify the filename (filename) and the printer port used (device), as in the following syntax:

print <filename> <device>

However, you should know the type of port your printer is using. For parallel ports, the printer name used starts with LPT. As for the serial port, the printer name starts with COM. To make it clearer, let’s look at the example below:

print c:\file.txt /d:lpt1

By running the example command, you will print a file.txt that is on the C: partition with the printer on port LPT1.

40. query

Supported in: all versions after Windows XP

query is a CMD command used to display four types of information related to the RD session host server . Each piece of information can be represented by the following syntax:

  • query process — display a list of processes running on the RD session host server
  • query session — display a list of existing sessions on the RD session host server
  • query termserver — display a list of RD session host servers on the local network
  • query user — displays information about user sessions on an RD session host server

41. recover

Supported in: all versions after Windows 98

If the hard drive is damaged, you can try to restore the data on it with the recover command.

However, you can only recover one file at a time. In addition, you must know the name of the file and its location. For example, as shown below:

recover d:\fiction\story.txt

42. rename

Supported in: all versions of Windows

As the name implies, the rename command is used to rename files and directories. Just like the previous command, rename requires you to specify the directory name of the selected file or directory.

For example, with the command below you can change the file “computer.jpg” to “text.jpg”:

rename d:/pictures/computer.jpg text.jpg

As a side note, you can also use the ren command to rename a file or directory. The syntax of this command is no different from that of the rename command.

43. repair-bde

Supported on: Windows 7, 8, and 10

repair-bde is also a command that works to save files from a damaged hard drive . However, it is used for hard drives encrypted with BitLocker.

To be able to use repair-bde, you must have another hard drive on your computer. It is used as a repository for files from a damaged hard drive .

The data on the second hard drive will be overwritten or overwritten with files that can be salvaged from the damaged hard drive . Therefore, it is recommended that you use an empty hard drive .

Also, you will need a recovery key , recovery key package , recovery password, or password to unlock the hard drive .

With several factors involved, repair-bde does sound complicated. However, the syntax is quite easy to understand:

repair-bde <inputvolume> <outputvolume> <-rk> <–rp> <-pw> <–kp>

The following is an explanation of each part of the syntax above:

  • inputvolume — the letter of the hard drive partition whose files you want to save
  • outputvolume — the letter of the hard drive partition that will be used to store the files
  • -rk — recovery key file from encrypted hard drive
  • -rp — recovery password to unlock encrypted hard drive
  • -pw — password to open an encrypted hard drive
  • -kp — recovery key package to unlock encrypted hard drives

Even if -rk is a file, you must specify the letter of the partition and the directory it is in.

To make it clearer, let’s see an example of using the repair-bde command below:

repair-bde c: d: -rk f:\RecoveryKey.bek

The command will try to move files from drive C: to drive D: with a recovery key file named RecoveryKey.bek.

For the use of the repair-bde command that uses the recovery key package , the example is as follows:

repair-bde C: D: -rp 111111-222222-333333-444444-555555-666666-777777-888888

44. replace

Supported in: all versions of Windows

The replace command is used to replace one or more files in a directory with another file. This command is useful if the same file exists in multiple directories and needs to be updated regularly.

The syntax is like this:

replace <drive1> <filename> <drive2> </p> </r> </s>

As you can see above, there are three options that can be used in the replace command, namely:

  • /p — displays a confirmation question before you change files on <drive2>
  • /r — used to replace files with read only attributes
  • /s – used to replace all files in subdirectories in <drive2>

Let’s see an example of its use below:

replace f:\phones.cli c:\ /s

With this command, all the “phones.cli” files in the C: partition and all of its subdirectories will be replaced with files in the F: partition.

45. rmdir

Supported in: all versions of Windows

rmdir is used to remove empty directories. However, this CMD command can also delete non-empty directories in Windows XP and later versions.

The simple usage is like this:

rmdir c:\test

If you want to delete files and subdirectories in them, you just add /s after the command above:

rmdir c:\test /s

You can also use the rd command to delete a directory as it has the same function as rmdir.

46. robocopy

Supported in: all versions after Windows XP

Previously you have learned about the copy command. robocopy has the same function, but it can also copy directories and partitions.

Its syntax is similar to that of the copy command. The difference is that the files you want to copy to the destination directory are listed after you specify the name of the directory:

robocopy <source> <destination> <file(s)> <option>

As can be seen above, after specifying the file you want to copy you can use one or more options. Here are some options that can be used:

  • /s — copy subdirectories that are in the source directory, unless the subdirectory is empty
  • /e — copy subdirectories in the original directory, whether they contain or not
  • /copyall — the information of the copied file is kept when it is copied to the destination directory
  • /nocopy — the information of the copied file is not saved when it is copied to the destination directory
  • /move — delete the original file after copying
  • /a — only copies files with the archive attribute
  • /a+:<attribute> — copies and defines file attributes. The attribute symbols are as mentioned earlier in the discussion about the attrib command
  • /a-:<attribute> — like the previous option, but removes file attributes
  • /ia: <attribute>-only copies files with the attributes you specify
  • /xa: <attribute> – excludes files with the attributes you specify
  • /xf file <filename> — exclude files whose names have a specific word
  • /xf dirs <directoryname> — exclude directories whose names have a specific word
  • /max: n-only copies files below the size you specify (n)
  • /min: n-only copies files above the size you specify (n)

47. schtasks

Supported in: all versions after Windows XP

At the beginning of this article you learned about the at command which is used to automate actions. Well, schtasks have the same function, but the syntax is different:

schtasks /parameter <arguments>

What the /parameter on schtasks means is its sub-command. Here are some of them:

  • /create — create an automation
  • /delete — deletes an automation
  • /query — display a list of automated commands
  • /change — change the settings of an automation
  • /run — run an automation
  • /end — stop a running automation

Whereas <arguments> are actions that are automated with schtasks. There are so many things you can do with this command. Below are some commonly used <arguments>:

  • /tr — specify the name of the file to run with schtasks and its directory
  • /tn – specifies the name of the automated action
  • /sc — specifies the automation frequency. You can specify it per minute, hour, day, week and month. You can even create automations that only run once.
  • /mo — specify the frequency in more detail. For example, you want to run a file every 120 minutes.
  • /d — specify the automation day
  • /m — specify the automation month
  • /i — specify the time interval between the automation of an action
  • /st — Specifies when the automation starts. You need to remember that the format used is 24 hours. So, if you want to set an action for 2pm, then type 14:00.
  • /et — set the time for automation to stop
  • /k — removes automation when it stops

So that you can understand it more easily, let’s look at the example below. The following example is used to create an automation called SecurityScript with the target file sec.vbs:

schtasks /create /tn "Security Script" /tr sec.vbs /sc minute /mo 100 /st 17:00 /et 08:00 /k

48. sfc

Supported in: all versions after Windows 98

The sfc or system file checker command is used to find and replace Windows system files with the correct version. This is especially useful if there is a problem in your computer system that is difficult to fix.

The syntax is quite easy to understand:

sfc /command

/command is a sub-command that can be used with sfc. The following is a list of sub-commands:

  • /scannow — find and repair corrupt system files
  • /verifyonly — looking for corrupt system files
  • /scanfile — scans for damage to selected files and repairs them. You need to name the file and directory to use this sub-command
  • /verifyfile — scans for damage to selected files. As in the previous sub-command, you need to name the file and directory

Below is an example of using the sfc command to scan for corruption in the kernel32.dll file and fix it:

sfc /VERIFYFILE=c:\windows\system32\kernel32.dll

49. shadow

Supported on: Windows XP, Vista, and 7

The shadow command can be used if you are managing an RD session host server . With it, you can control other computers on the server. Here is the syntax:

shadow {<SessionName> | <SessionID>} [/server:<ServerName>] [/v]

So, you can control a computer on the RD session host server by simply mentioning the session name or ID. For example in the following example:

shadow 93

With this command, you will control the computer with ID 93.

50. shutdown

Supported in: all versions after Windows 2000

If you want to shut down , sleep , or log off your computer from the Command Prompt, you can use the shutdown command. In addition, you can also use it to do the same on other computers on a network.

The syntax is simple, but there are a few arguments you can use with this CMD command:

shutdown <arguments> <TargetComputer>

Here are some frequently used arguments or sub-commands:

  • /i — displays graphical user interface or GUI shutdown
  • /l — log off from the computer
  • /s – shut down or turn off the computer
  • /r – restart the computer
  • /a – cancel computer shutdown
  • /p — shuts down computers on the local network directly. This means that the computer shutdown GUI you normally see will not be displayed
  • /h — turn on hibernate mode
  • /t — the specified amount of time before one of the sub-commands is executed

So, if you want to shut down your personal computer, you can run the following command:

shutdown /i /s

However, if you are managing a local network and want to shut down one of the computers, below is an example of the required command:

shutdown /i /s /t 45

CMD command: Close

After reading this article, you should know that there are tons of CMD commands that you can use. Its functions also vary, ranging from basic operations such as copying and moving files to managing computers on a local network.

Well, from now on you can use the commands in this article to use the Command Prompt. If you have any questions, don’t hesitate to leave your comments in the column provided below.