Some Basic Commands of Command Prompt

1.cd\ Go to the top of the directory tree.

  • CD (Change Directory): Change the current folder or navigate to another folder.
C:\Users\LillianSIYIN>cd\
C:\>

2.cd.. Go back to one folder up.

C:\Users\LillianSIYIN>cd..
C:\Users>

3.e: Directly accesses to another drive (e drive).

C:\Users\LillianSIYIN>e:
E:\>

4.cd /d ... Changes the drive and the directory at the same time.

C:\Users\LillianSIYIN>cd /d e:\windows
E:\windows>

5.dir View the contents of a folder.

E:\SA>dir
   Volume in drive E has no label.
   Volume Serial Number is B8E7-1B00
   Directory of E:\SA
 03/30/2017  11:22 AM    <DIR>          .
 03/30/2017  11:22 AM    <DIR>          ..
 02/21/2017  02:33 PM       107,276,552 Enterprise Architecture.zip
 10/26/2016  08:15 PM    <DIR>          term1
 01/11/2017  05:48 PM    <DIR>          term2
 03/30/2017  11:22 AM    <DIR>          term3
               1 File(s)    107,276,552 bytes
               5 Dir(s)  35,814,080,512 bytes free
E:\SA>

6.mkdir ... or md ... (make directory) Creates a new folder or makes a new directory

C:\>md my_folder
C:\>

NOTE:

  • All these commands depend on the current location in the Command Prompt.
    Eg, if you are on the “C:” drive and type mkdir test, test will be created at “C:” drive.
  • Otherwise, is to type the complete path of the new folder.
    Eg, if you are at “C:” drive and you want to create my_folder in “E:”,type mkdir e:\my_folder.
C:\>md e:\my_folder
C:\>

7.ren ... (rename) Rename files and folders.

E:\SA>ren term1 TermOne
E:\SA>

8.copy ... ... Allow to copy files from one location to another.

You will receive a confirmation of the operation as below:

D:\Photos>copy IMG_0462.JPG e:\IMG_0462.JPG
        1 file(s) copied.

D:\Photos\about me>

NOTE: If you are copying within the same directory, don't have to put the path.

C:\Users\LillianSIYIN\Desktop>copy idea.docx idea.txt
        1 file(s) copied.

C:\Users\LillianSIYIN\Desktop>

9.xcopy /s /i ... ... (rename) Rename files and folders.

  • The /s parameter will ensure that all the directories and sub-directories will be copied, except the ones that are empty.
  • The /i parameter will create a new directory if the destination folder doesn't exist and will copy all the files.
E:\>xcopy /s /i e:\travel "c:\Users\LIN SIYIN\Desktop"\travel
E:\travel\abc.txt
1 File(s) copied
E:\>

10.del ... (delete) To delete all the files from the specified folder.

E:\>del travel
E:\travel\*, Are you sure (Y/N)? y
e:\>

NOTE:

  • To also delete hidden files from the folder, must add the /h parameter.
  • The del cammand doesn’t work for deleting the folder (view E:\>dir and E:\travel>dir):
E:\>dir
  Volume in drive E has no label.
  Volume Serial Number is B8E7-1B00
  Directory of E:\
04/05/2017  11:01 AM    <DIR>          OCBC
03/30/2017  11:27 AM    <DIR>          others
11/14/2016  03:41 PM                40 product key.txt
03/30/2017  11:22 AM    <DIR>          SA
04/05/2017  05:49 PM    <DIR>          travel
01/11/2017  05:54 PM    <DIR>          Unity
               1 File(s)             40 bytes
               5 Dir(s)  35,814,080,512 bytes free

E:\>cd travel
E:\travel>dir
 Volume in drive E has no label.
 Volume Serial Number is B8E7-1B00
 Directory of E:\travel
04/05/2017  05:49 PM    <DIR>          .
04/05/2017  05:49 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  35,814,080,512 bytes free

Some useful DEL combinations that are worth mentioning:

  1. DEL *.DOC - delete all .dco files (you can use any file extension);
  2. DEL Test*.* - delete all files beginning with Test;
  3. DEL *.* - delete ALL files from the current folder.

11.RD (remove directory) Delete the empty folder.

  • The RD command can only delete an empty folder.
E:\>RD travel
The directory is not empty.

E:\>del travel
E:\travel\*, Are you sure (Y/N)? y

E:\>RD travel

E:\>dir
 Volume in drive E has no label.
 Volume Serial Number is B8E7-1B00

 Directory of E:\

04/05/2017  11:01 AM    <DIR>          OCBC
03/30/2017  11:27 AM    <DIR>          others
11/14/2016  03:41 PM                40 product key.txt
03/30/2017  11:22 AM    <DIR>          SA
01/11/2017  05:54 PM    <DIR>          Unity
               1 File(s)             40 bytes
               4 Dir(s)  35,814,080,512 bytes free

E:\>

12.How to launch an application?

To run a program from the Command Prompt, you need only to navigate to the folder that contains the executable and type the program’s name.
For example, if you want to launch Paint , go to C:\Windows\System32 and you will find the executable called mspaint.exe. Then write mspaint.exe or simply mspaint and press Enter. Both commands and paint can be seen.

C:\Windows\System32>mspaint.exe
C:\Windows\System32>

13.How to get help in Command Prompt

  1. help A list with all available commands will be displayed:
C:\Windows\System32>help
For more information on a specific command, type HELP command-name
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.

For more information on tools see the command-line reference in the online help.

C:\Windows\System32>
  1. Type help followed by the name of that command or type the command’s name followed by the /? parameter: Looking into a specified command.
C:\Windows\System32>help cd
Displays the name of or changes the current directory.

CHDIR [/D] [drive:][path]
CHDIR [..]
CD [/D] [drive:][path]
CD [..]

  ..   Specifies that you want to change to the parent directory.

Type CD drive: to display the current directory in the specified drive.
Type CD without parameters to display the current drive and directory.

Use the /D switch to change current drive in addition to changing current
directory for a drive.

If Command Extensions are enabled CHDIR changes as follows:

The current directory string is converted to use the same case as
the on disk names.  So CD C:\TEMP would actually set the current
directory to C:\Temp if that is the case on disk.

CHDIR command does not treat spaces as delimiters, so it is possible to
CD into a subdirectory name that contains a space without surrounding
the name with quotes.  For example:

    cd \winnt\profiles\username\programs\start menu

is the same as:

    cd "\winnt\profiles\username\programs\start menu"

which is what you would have to type if extensions were disabled.

C:\Windows\System32>

or

C:\Windows\System32>copy /?
Copies one or more files to another location.

COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B]
     [+ source [/A | /B] [+ ...]] [destination [/A | /B]]

  source       Specifies the file or files to be copied.
  /A           Indicates an ASCII text file.
  /B           Indicates a binary file.
  /D           Allow the destination file to be created decrypted
  destination  Specifies the directory and/or filename for the new file(s).
  /V           Verifies that new files are written correctly.
  /N           Uses short filename, if available, when copying a file with a
               non-8dot3 name.
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.
  /L           If the source is a symbolic link, copy the link to the target
               instead of the actual file the source link points to.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.  Default is
to prompt on overwrites unless COPY command is being executed from
within a batch script.

To append files, specify a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format).

C:\Windows\System32>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,717评论 6 496
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,501评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,311评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,417评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,500评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,538评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,557评论 3 414
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,310评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,759评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,065评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,233评论 1 343
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,909评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,548评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,172评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,420评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,103评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,098评论 2 352

推荐阅读更多精彩内容