Today, I take out some of my own learning materials on DOS for newbies to learn, aiming to improve everyone's mastery of DOS.
There is a requirement that you must learn the basics of DOS.
After learning the basics of DOS, if you can master the following things, you can be a little expert. Experience and learn by yourself!!!
100 DOS Tips
1. Short form of *.*
*.* can be replaced by ., for example, to delete all files in the current directory:
DEL.
2. Return to the parent directory, i.e., the upper-level directory
CD..
3. Save the list of directory files into a text file
DIR>filename
4. View any attribute files in the current directory
Method 1: DIR
Method 2: DIR /A
5. Cancel all attributes of all files in the current directory
ATTRIB
If this command is executed in the root directory of drive C, and then DIR is used to view, you can see hidden files such as IO.SYS, MSDOS.SYS, etc.
6. Display all subdirectory names in the current directory
DIR /AD
7. Continuously display the contents of multiple files
COPY *.* CON
8. Display file contents in split screen
Method 1: MORE<filename
Method 2: TYPE filename|more
9. Change the registration time of disk files
Method 1: COPY filename+NUL
Method 2: COPY filename+,,
10. How to shield the output information of DOS lines?
The method is to redirect the screen output to the DOS null device NUL. For example:
COPY MYPROG.EXE A:>NUL
11. Directly display the content of a WPS file edited in D mode under DOS status
COPY filename.wps CON/B
12. Append data to a text file
Method 1: COPY filename+CON
Method 2: TYPE CON>>filename
Press F6 or Ctrl+Z key to end after input is complete.
13. Simple screen for keyboard typing practice or Chinese character input practice
COPY CON NUL
14. Directly print the content typed on the keyboard
Method 1: COPY CON PRN
Method 2: MORE>PRN
Method 3: SORT>PRN
Press F6 or Ctrl+Z key after input is complete.
15. Directly edit and generate files under DOS
In the absence of any editing software (such as EDLIN, EDIT, etc.), you can temporarily use the following six methods to edit and generate files from the keyboard. When the file content is input complete, press F6 key or Ctrl+Z key to save and exit:
Method 1: COPY CON filename
Method 2: TYPE CON>filename
Method 3: MORE>filename
Method 4: SORT>filename
Method 5: FIND"XXX" /V /N>filename
Method 6: SORT|FIND"XXX" /V /N>filename
Methods 4, 5, and 6 all have special uses. Readers may as well give it a try.
16. Generation of zero-byte files
Method: TYPE NUL>filename
The above method is often used to handle disk files that need to be kept secret, playing the role of deleting the file content. The content is generally not recoverable after being deleted.
17. Copying zero-byte files cannot use the COPY command, only the XCOPY command.
For example: XCOPY filename1 filename2
18. Copy all files and subdirectories in the directory
XCOPY directory name. drive letter:/S
19. How to correctly use COPY and XCOPY commands?
● When concatenating several files into one file, the COPY command should be used.
● To copy a single file smaller than 64KB, use the COPY command. To copy a file larger than 64KB, use the XCOPY command.
● To copy multiple files, use the XCOPY command.
● To copy the content in subdirectories, use the XCOPY/S command. To copy a batch of files to a floppy disk, use the XCOPY/M command.
20. When to use the /D switch item of the XCOPY command?
Sometimes, you need to "select" files that were created or modified from a certain day in a certain directory and back them up. At this time, the XCOPY/D command can be used. For example, the following command can copy files that were created or modified after July 1, 1996 in the C: directory to drive A:
XCOPY C:*.* A:/D:07-01-96
21. Copying floppy disks with a single floppy drive
Some PCs only have one floppy drive, which is used as both drive A and drive B. If you need to copy floppy disks on such a system, use the following XCOPY command:
XCOPY A: B:
22. Organizing fragments in a floppy disk to improve use efficiency
After multiple operations of creating and deleting files on a floppy disk, some file records will be stored in a discontinuous form in the floppy disk space, causing many fragments in the floppy disk space, affecting the read and write operation performance of the floppy disk, and seriously causing read and write failures.
To solve the above problem, the COPY command can be used to copy the entire disk, and the files on the new disk will be stored continuously.
23. Continuously copying multiple files to multiple floppy disks.
First, use the ATTRIB command to set the document attributes of each file:
ATTRIB+A *.* /S
Then use the XCOPY command. When the floppy disk is full, insert a new disk, and decide which files need to be copied and which do not according to the document attributes.
XCOPY *.* A:/S/M/W
24. Using the TYPE command to "copy" files
The COPY command or XCOPY command is usually used to copy files. In fact, TYPE also has the use of "copying" files:
TYPE filenamel>filename2
This method is very effective for copying hidden files. For example: TYPE IO.SYS>A:IO.SYS
25. Displaying files or directories in lowercase
DIR /L
26. Only displaying file names and subdirectory names, not displaying file sizes and generation times and other information
DIR /B
27. Making DIR always display files in alphabetical order by file name
Just add the following command in AUTOEXEC BAT:
SET DIRCMD=/O
28. Listing the directory of files created on the current day
If you want to know how many files were created on the current day (such as October 21, 1996), you can use the following command to list:
DIR|FIND"10 21 1996"
29. If you do not want others to use the DIR command to list directory files, what methods are there?
Method 1: DOSKEY DIR=You can not use DIR!
Method 2: Add the command line in AUTOEXEC BAT: SET DIRCMD=0
The function of this command is to only display "File not found" when using the DIR command to display files, which can play a temporary secret-keeping role. If you want to display files and directories, you can only specify the specific file name or path.
Method 3: SET DIRCMD=DIR>NUL
After executing this command and then using the DIR command, the information of no files will be output, which is also very confusing.
30. Output all files in the directory
CHKDSK /V|MORE
31. How to find files on a disk with multiple levels of directories
Method 1: CHKDSK /V|FIND"file name" where the file name must be in uppercase letters.
Method 2: DIR /S file name
32. Real-time control of printer line feed or page feed
ECHO+>PRN (line feed)
ECHO^L>PRN (page feed)
33. Making the computer make a sound at the DOS command line
ECHO ^G
34. Automatic response to DOS command questions
For example:
ECHO Y|DEL C:
ECHO N|CHKDSK C:/F
35. Making the ECHO command display an empty line
When the ECHO command is directly followed by a space character, ECHO will display the current information echo status (ON or OFF), and not directly echo an empty line to the screen. In fact, the following some very simple command formats can all make the ECHO command display an empty line:
ECHO ECHO, ECHO; ECHO+
ECHO[ ECHO] ECHO/ ECHO\par
36. Using the ECHO command to feed a carriage return to an interactive DOS command
For example:
ECHO+|DATE|FIND"Current date"
ECHO+|TIME|FIND"Current time"
This skill can be used in AUTOEXEC.BAT, so that the current date and time information is directly displayed after each boot, and you don't need to press the Enter key to continue.
37. Boot time black box
Sometimes it is necessary to record the date and time of each use of the computer to strengthen the computer usage management. You can use the above skills. Just add the following commands in the AUTOEXEC.BAT file:
ECHO+|DATE>>ABC
ECHO+|TIME>>ABC
In this way, after each computer startup, the date and time will be automatically recorded in file ABC, and the command TYPE ABC can be executed to view the previous boot date and time.
38. Automatically counting the running time of commands or files
The following is a timer TIMETEST.BAT, which realizes the automatic counting of the running time of commands or files:
@ECHO OFF
TIME 0
COMMAND /C %1 %2 %3 %4
ECHO %1 %2 %3 %4 running time is:
ECHO+|TIME|FIND"time is"
@ECHO ON
For example, test the running time of AUTOEXEC.BAT:
C>TIMETEST AUTOEXEC.BAT ┆
The running time of AUTOEXEC.BAT is:
Current time is 0:00:03 49
It shows that AUTOEXEC.BAT ran for 3.49 seconds.
39. Skipping or stepping through the CONFIG.SYS and AUTOEXEC.BAT files
Method 1: Start the computer, when the screen shows "Starting MS-DOS…", press the F5 key or the SHIFT key, and DOS will skip the two files CONFIG.SYS and AUTOEXEC.BAT, and start the machine with the basic environment configuration of the system operation.
Method 2: When the above prompt appears, press the F8 key, and answer Y or N one by one through the keyboard to select the execution command.
Method 3: Add a "?" sign in the command of the CONFIG.SYS file. For example, DOS?=UMS, so when this command is executed, a selection prompt [Y, N]? will appear, allowing you to choose whether to load this command.
40. Can the two-second time of waiting to press F8 or F5 when DOS starts be omitted?
Yes. The method is to add the statement SWITCHES=/F at the head of the CONFIG SYS file. After that, the previous function can be realized in the same way. The method is to press the F8 or F5 key before the "Starting MS-DOS…" appears.
41. Step-by-step execution of a batch file
COMMAND/Y/C (batch file name)
The switch /Y tells DOS to pause before executing each line and ask the user whether to execute with [Y, N]?.
42. Quickly obtaining help information for DOS commands
Method 1: FAST HELP command name
Method 2: command name/?
Method 3: command name/H
43. Conveniently changing the subdirectory name
The following MOVE command can change the C: directory to C::
MOVE C: C:
44. When to use the MOVE command to move files?
The biggest feature of the MOVE command is that multiple files to be moved can be listed in one command line, and the files can be separated by ",". For example, move all executable files in the current directory into the directory:
MOVE *.COM,*.EXE,*.BAT
45. Using the MOVE command to simply encrypt or decrypt subdirectories
Encryption: For example, to simply encrypt the C: directory with a half-Chinese character, the executable command can be:
MOVE C: C(half-Chinese character)
Decryption: Conversely, the MOVE command combined with the wildcard * or? can be used to change the unrecognizable directory name to another name to achieve the decryption purpose.
46. Quickly entering a deep subdirectory
The SUBST command can be used to set the drive identifier to replace the deep subdirectory path, making it very convenient to enter the deep subdirectory. For example, the following command can simulate the subdirectory C: as drive M:
SUBST M: C:
In this way, in any directory, as long as the current drive is changed to M, you can enter the PRG subdirectory.
47. How to cancel the drive letter set by SUBST?
For example, to cancel the M drive in the above example, just execute the command SUBST M:/D.
48. The MD command to create and enter a new directory
The MD command in DOS can only create subdirectories. After creating, use the CD command to enter. In fact, you can use:
DOSKEY MD=MD $1 $T CD $1
Redefine the MD command. After that, when using MD, the creation of the directory and the entry into the directory are completed synchronously.
49. Exclusion method file listing
The DIR command supports wildcards * and? to replace other characters, but it does not provide the corresponding function of excluding characters. However, using the /V parameter in the FIND command, the exclusion method listing can be easily realized. The following command can list all files except.BAK files and subdirectories:
DIR|FIND/V"BAK"|FIND/V"<DIR>"
50. Difference between > and >>
DIR>DIRLIST: If the DIRLIST file exists, its file content will be cleared, and the new content will be input into the file.
DIR>>DIRLIST: If the DIRLIST file exists, the output data will be appended to the end of this file.
When the DIRLIST file does not exist, the two are equivalent.
51. Quickly adding a search path
PATH=%PATH%;%1
52. For data files and text files generated by word processing programs and other non-executable files, establish an automatic search path.
The APPEND command can add a group of specified directories to the logical extension of the current directory, so that these files can be opened without specifying the path. Multiple directories can be placed after APPEND, as long as they are separated by ";", for example:
APPEND C:;C:;C:;C:;
53. Hiding the directory name
Since the ATTRIB command can change the attribute of a directory, the directory name can be hidden by using this command. For example, hide the directory C::
ATTRIB +H C:
54. Quickly deleting the directory tree
The DELTREE command can quickly delete the specified directory, regardless of how many subdirectories and directories are in the directory and what the attributes of the files are. For example: DELTREE C:
55. Preventing accidental deletion of files
The DEL command is a dangerous command. You can redefine it with the following command to make it have a confirmation prompt when deleting files:
DOSKEY DEL=DEL $1/P
56. If some files are accidentally deleted, is there any way to recover them in time?
The UNDELETE command can be used to recover deleted files. The following command can recover the deleted files in the current directory:
UNDELETE *.*/ALL
The first character of the file name recovered by this command becomes #, and the original file name can be changed with the REN command.
57. When deleting multiple files with no common characteristics in the file name, since it is difficult to use wildcards, they can only be deleted one by one, which is more troublesome. Is there any other convenient method?
Yes. Use the DEL *.* /P command, the system will list all files in the specified directory one by one, ask the user whether to delete, answer Y for the file to be deleted, otherwise answer N.
58. One method of encrypting the file name
Add ASCII character 255 at the end of the file name to be encrypted. The method is to press the ALT key after entering the file name, and then enter 255. In this way, when the DIR command lists the file, this character is not displayed, that is, it cannot be seen from the file name that any change has occurred, which plays a certain encryption role.
59. Recalling used commands
After executing the DOSKEY command, the commands entered by the user are stored. Later, if you want to recall the used commands, you can use the "↑" or "↓" keys to search forward and backward one by one at any time.
60. Prohibiting illegal access to a certain drive
Add the following two commands in the AUTOEXEC.BAT file to prohibit illegal access to drive D. When entering D:, the screen will be closed, and only those who know the password ZM can enter drive D:
DOSKEY D:=ECHO OFF
DOSKEY ZM=D:
61. Preventing others from accidentally formatting drive C
To protect drive C and prevent others from formatting it, the FORMAT command can be redefined with DOSKEY. For example:
DOSDEY FORMAT=You can not format C:!
In this way, when others use FORMAT, the prompt Yor can not format C:! will appear, so that drive C is protected. If you want to use FORMAT yourself, restore it with the following command:
DOSKEY FORMAT=
62. Checking the screen status and obtaining a report on the display characters and lines of the screen
MODE CON
63. Setting the number of characters per line and the number of lines per screen of the screen
For example:
MODE CON COLS=80 LINES=25
64. Improving the response speed of the keyboard
MODE CON:RATE=32 DELAY=1
65. If you don't like the default setting of the Num Lock key when the system starts, what should you do?
Add the NUMLOCK command in the CONFIG SYS file, and specify the state of the NUMLOCK key when the system starts according to your preference:
NUMLOCK=ON(or OFF)
66. Simple keyboard lock
When you are using the computer and only leave for a while and don't want to shut down, in order to prevent others from using it casually, you can compile a simple keyboard lock LOCK BAT program (the content is as follows):
@ECHO OFF
CLS
CHOICE/C:* /N
After running, it is like a dead machine. The "*" is the key of the keyboard lock, and those who don't know it can't decipher it.
67. Selective display of files
Suppose there are 10 files such as MY1 TXT, MY2 TXT,..., MY10.TXT. Now, if you want to display 4 files among them: MY2.TXT, MY3.TXT, MY6.TXT, and MY9.TXT, you can use the following command to realize it very conveniently:
FOR %A IN(2369)DO TYPE MY%A.TXT
68. Deleting mistakenly copied files
When using the COPY A:*.* command to copy all files on drive A to a subdirectory of the hard disk, but accidentally copied them to the root directory of the hard disk. If a large number of mistakenly copied files are involved and the file names have no characteristics, at this time, if you want to delete these files, the usual practice is to use the PCTOOLS tool software for selective deletion, which is more troublesome. Using the FOR command is much simpler:
A>FOR %A IN(*.*)DO DEL C:%A
69. Since the FIND command cannot accept wildcards, if you want to find a certain string in several text files, you can only use the FIND command for each file in turn, which is obviously very time-consuming. Is there no shortcut?
Yes. Use the FOR command in combination with the FIND command. The format is:
FOR%A IN(文件组)DO FIND"string"%A
70. The FOR command cannot be nested. Is there a way to realize FOR loop nesting?
Yes. You can use COMMAND.COM as the command in the first-level loop to let it execute another FOR loop command. For example, the following command can display 12 lines of "Welcome you" on the screen: FOR %A IN(123)DO COMMAND/C FOR %B IN(1234)DO ECHO Welcome you
71. The role of double colons :: in the comment line
At the beginning of the DOS batch file, the REM comment command is often used to add a program header. For example, suppose there is a batch file named TEST.BAT, which uses a text file name as an input parameter. When explaining its usage at the beginning, a comment line using < and > and parentheses is used, that is:
REM TEST<filename>
When the program executes this command, DOS will display the "File not found" information because it thinks that filename is a source file for a redirect input operation, and it cannot be found in the current directory. How to solve this problem?
It's very simple. Just change REM to double colon "::", that is:
::TEST<filename>
72. IF ERRORLEVEL in batch processing
When using the IF ERRORLEVEL command in a batch file, be careful because DOS considers any exit status value greater than or equal to the set value to be equivalent. Usually, the exit status value should be tested in descending order. For example:
IF ERRORLEVEL 2 ECHO TWO
IF ERRORLEVEL 1 ECHO ONE
IF ERRORLEVEL 0 ECHO ZERO
73. Can the exit status value be tested in ascending order?
Yes. But it should be judged in combination with the form of IF NOT. For example, the commands in example 72 should be changed to:
IF ERRORLEVEL 0 IF NOT ERRORLEVEL 1 ECHO ZERO
IF ERRORLEVEL 1 IF NOT ERRORLEVEL 2 ECHO ONE
IF ERRORLEVEL 2 IF NOT ERRORLEVEL 3 ECHO TWO
74. Using the @ symbol in batch files to prohibit commands from being displayed on the screen
Since DOS displays each command on the screen before executing it, even if you set the ECHO command to OFF, it will itself appear on the screen. To suppress its display, you can add the @ symbol before the ECHO command line: @ ECHO OFF
75. Counting the number of lines of the source program
Suppose the source program is named ZM.PRG. The following FIND command can conveniently count how many lines it has:
FIND/V/C" "ZM.PRG
76. Sorting text files
The SORT command is often used to sort and display some text line-based files. For example, display a list file containing phone numbers according to the first letter of the name. Command format:
SORT[/R][/+n]<filename1>filename2
Among them, /R means reverse sorting, /+n means starting from which line to sort, filename1 is the source file name, and filename2 is the sorted file name.
77. Using PROMPT to set a meaningful prompt
The PROMPT command is used to set a new DOS system prompt. For example:
PROMPT $P$G Get the current drive name and directory as the prompt
PROMPT $D$G Get the current system date as the prompt.
78. How to set the screen color?
Suppose ANSI.SYS has been installed in memory. The following command can set the screen to white background and red characters:
PROMPT $E[31;47m
79. Displaying date and time information at the selected position on the screen
Combining the screen and cursor control functions of ANSI SYS with the function of setting the DOS command prompt of PROMPT, special information can be displayed at the selected position on the screen. For example, add the following command line in AUTOEXEC BAT, and the date and time information can be moved to the lower right corner of the screen:
PROMPT $E[S $E[25;52H $D$T $E[u $P$G
80. Editing the last command with the F2 key
The F1 or F3 function key can be used to copy the last command. Similarly, the F2 key can get part of the last command. When the F2 key is pressed, DOS will copy the content of the last command to the character typed after pressing the F2 key (excluding).
For example, the following command is typed:
C>DIR.COM<enter>
Press the F2 key and the M key, and you can get:
C>DIR
At this time, press the INS insert key again, enter R, and then press the F3 key to copy the remaining part of the last command, and get the correct command:
C>DIR.COM
81. Editing the last command with the F4 key
When the F4 key is pressed, DOS copies the last command starting from the letter pressed after the F4 key. For example, the last command is:
C>DIR[enter]
Press the F4 key, then enter F, and then press F3, DOS will display the FORMAT command:
C>FORMAT
82. Using the SHELL command to change the size of the environment space
Increase the environment variable space to 1KB. You can add the command line in the CONFIG.SYS file:
SHELL=C:.COM/P/E:1024
83. Referring to environment variables in batch files
Batch files can refer to environment variables defined on the system. The specific method is to put a percent sign "%" before and after the environment variable name. For example, to display the content of the environment variable PATH in the batch file, you can add the command line:
ECHO %PATH%
84. Viewing a single environment variable
If you often use environment variables, when using the SET command to display all currently allocated environment variables, the list may be very long and the screen may be messy. For convenience, you can use the following batch file VIEWENV.BAT to directly display a single environment variable on the command line:
SET|FIND/I "%1"
For example, to view the content of COMSPEC, just execute:
VIEWENV COMSPEC
85. Making a DOS system disk
Method 1: FORMAT A:/S
Method 2: SYS A:
86. Regularly organizing the hard disk
Specific steps:
· Delete unnecessary files on the hard disk
· Run CHKDSK/F
· Run DEFRAG
87. Understanding the types of memory
· Conventional memory: 0-640KB
· Upper memory area (UMA): 640KB-1MB
· Extended memory: extends upward from 1MB
· High memory area (HMA): an extended memory area slightly less than 64KB above 1MB
· Expanded memory
88. Moving DOS to the high memory area
To enable users to have a larger available basic memory, the following command can be added in the CONFIG.SYS file to load HIMEM.SYS and move DOS to the high memory area (HMA):
DEVICE=C:.SYS
DOS=HIGH
89. Loading device drivers and memory-resident programs into upper memory (UMB)
Add the command in the CONFIG.SYS file:
DEVICE=C:.EXE NOEMS
DOS=UMB
90. Loading programs into the high memory area
The method to load the program into HMA is to add a /U switch on the command line. For example:
MOUSE/U
91. Use of upper memory
To make the program reside in upper memory, use LOADHIGH (or LH)<program name> that is, for example:
LH MOUSE
92. How to display the memory usage of a specific program?
MEM/M module
Among them, module represents the specific program file name, without the extension.
93. Using Memmaker to automatically optimize memory
Execute the MEMMAKER/BATCH command, and MEMMAKER will automatically make the optimal settings for the CONFIG.SYS and AUTOEXEC.BAT files. After that, execute MEM/C/P to observe the memory allocation situation, and you will find that the main memory has become larger.
94. If you are not satisfied with the optimization settings of MEMMAKER, what should you do?
It's very simple. Just execute MEMMAKER/UNDO to restore your original configuration.
95. Use of disk cache SMARTDRV
To create a disk cache with 256K (default value), you can add the command line in the AUTOEXEC.BAT file:
C:
Since SMARTDRV is built in extended memory, you must also add the command line in the CONFIG.SYS file:
DEVICE=C:.SYS
96. When you shut down the computer or restart it, if you want to make sure that all information in the cache is written to the hard disk, you should type the command at the system prompt:
SMARTDRV/C
97. Skipping the magnetic medium scan of SCANDISK
When running SCANDISK, the magnetic medium scan takes a long time. In fact, using SCANDISK/CHECKONLY can skip it.
98. Correct use of the LOADFIX command
During the optimization process, a few programs cannot run correctly in the low 64KB of the 640KB conventional memory. At this time, the LOADFIX command can be used to let the executable program (such as ZMPROG.EXE) run in the memory above the low 64KB. The method is to add LOADFIX before the application program to be run:
LOADFIX ZMPROG
99. When to use a virtual disk (also called RAM disk)?
The RAM disk can significantly improve the access speed of disk files, but it will lose data when the power is off or restarted. Therefore, special care should be taken when using the RAM disk. The RAM disk is worth using on a system without a hard disk; it can also be used when you need to store larger temporary files or copy programs; when your system is equipped with a CD-ROM, you can copy the files and data on the CD-ROM disk into the RAM disk before starting work, which can significantly improve efficiency.
100. Installation of the virtual disk
The RAMDRIVE.SYS provided by DOS is a virtual disk driver. You can install it into the memory, let it use extended memory or expanded memory, and generate a RAM disk of the specified size. For example, add the following command in CONFIG.SYS, and a 1MB RAM disk can be generated in the extended memory:
DEVICE=C:.SYS 1024/E
There is a requirement that you must learn the basics of DOS.
After learning the basics of DOS, if you can master the following things, you can be a little expert. Experience and learn by yourself!!!
100 DOS Tips
1. Short form of *.*
*.* can be replaced by ., for example, to delete all files in the current directory:
DEL.
2. Return to the parent directory, i.e., the upper-level directory
CD..
3. Save the list of directory files into a text file
DIR>filename
4. View any attribute files in the current directory
Method 1: DIR
Method 2: DIR /A
5. Cancel all attributes of all files in the current directory
ATTRIB
If this command is executed in the root directory of drive C, and then DIR is used to view, you can see hidden files such as IO.SYS, MSDOS.SYS, etc.
6. Display all subdirectory names in the current directory
DIR /AD
7. Continuously display the contents of multiple files
COPY *.* CON
8. Display file contents in split screen
Method 1: MORE<filename
Method 2: TYPE filename|more
9. Change the registration time of disk files
Method 1: COPY filename+NUL
Method 2: COPY filename+,,
10. How to shield the output information of DOS lines?
The method is to redirect the screen output to the DOS null device NUL. For example:
COPY MYPROG.EXE A:>NUL
11. Directly display the content of a WPS file edited in D mode under DOS status
COPY filename.wps CON/B
12. Append data to a text file
Method 1: COPY filename+CON
Method 2: TYPE CON>>filename
Press F6 or Ctrl+Z key to end after input is complete.
13. Simple screen for keyboard typing practice or Chinese character input practice
COPY CON NUL
14. Directly print the content typed on the keyboard
Method 1: COPY CON PRN
Method 2: MORE>PRN
Method 3: SORT>PRN
Press F6 or Ctrl+Z key after input is complete.
15. Directly edit and generate files under DOS
In the absence of any editing software (such as EDLIN, EDIT, etc.), you can temporarily use the following six methods to edit and generate files from the keyboard. When the file content is input complete, press F6 key or Ctrl+Z key to save and exit:
Method 1: COPY CON filename
Method 2: TYPE CON>filename
Method 3: MORE>filename
Method 4: SORT>filename
Method 5: FIND"XXX" /V /N>filename
Method 6: SORT|FIND"XXX" /V /N>filename
Methods 4, 5, and 6 all have special uses. Readers may as well give it a try.
16. Generation of zero-byte files
Method: TYPE NUL>filename
The above method is often used to handle disk files that need to be kept secret, playing the role of deleting the file content. The content is generally not recoverable after being deleted.
17. Copying zero-byte files cannot use the COPY command, only the XCOPY command.
For example: XCOPY filename1 filename2
18. Copy all files and subdirectories in the directory
XCOPY directory name. drive letter:/S
19. How to correctly use COPY and XCOPY commands?
● When concatenating several files into one file, the COPY command should be used.
● To copy a single file smaller than 64KB, use the COPY command. To copy a file larger than 64KB, use the XCOPY command.
● To copy multiple files, use the XCOPY command.
● To copy the content in subdirectories, use the XCOPY/S command. To copy a batch of files to a floppy disk, use the XCOPY/M command.
20. When to use the /D switch item of the XCOPY command?
Sometimes, you need to "select" files that were created or modified from a certain day in a certain directory and back them up. At this time, the XCOPY/D command can be used. For example, the following command can copy files that were created or modified after July 1, 1996 in the C: directory to drive A:
XCOPY C:*.* A:/D:07-01-96
21. Copying floppy disks with a single floppy drive
Some PCs only have one floppy drive, which is used as both drive A and drive B. If you need to copy floppy disks on such a system, use the following XCOPY command:
XCOPY A: B:
22. Organizing fragments in a floppy disk to improve use efficiency
After multiple operations of creating and deleting files on a floppy disk, some file records will be stored in a discontinuous form in the floppy disk space, causing many fragments in the floppy disk space, affecting the read and write operation performance of the floppy disk, and seriously causing read and write failures.
To solve the above problem, the COPY command can be used to copy the entire disk, and the files on the new disk will be stored continuously.
23. Continuously copying multiple files to multiple floppy disks.
First, use the ATTRIB command to set the document attributes of each file:
ATTRIB+A *.* /S
Then use the XCOPY command. When the floppy disk is full, insert a new disk, and decide which files need to be copied and which do not according to the document attributes.
XCOPY *.* A:/S/M/W
24. Using the TYPE command to "copy" files
The COPY command or XCOPY command is usually used to copy files. In fact, TYPE also has the use of "copying" files:
TYPE filenamel>filename2
This method is very effective for copying hidden files. For example: TYPE IO.SYS>A:IO.SYS
25. Displaying files or directories in lowercase
DIR /L
26. Only displaying file names and subdirectory names, not displaying file sizes and generation times and other information
DIR /B
27. Making DIR always display files in alphabetical order by file name
Just add the following command in AUTOEXEC BAT:
SET DIRCMD=/O
28. Listing the directory of files created on the current day
If you want to know how many files were created on the current day (such as October 21, 1996), you can use the following command to list:
DIR|FIND"10 21 1996"
29. If you do not want others to use the DIR command to list directory files, what methods are there?
Method 1: DOSKEY DIR=You can not use DIR!
Method 2: Add the command line in AUTOEXEC BAT: SET DIRCMD=0
The function of this command is to only display "File not found" when using the DIR command to display files, which can play a temporary secret-keeping role. If you want to display files and directories, you can only specify the specific file name or path.
Method 3: SET DIRCMD=DIR>NUL
After executing this command and then using the DIR command, the information of no files will be output, which is also very confusing.
30. Output all files in the directory
CHKDSK /V|MORE
31. How to find files on a disk with multiple levels of directories
Method 1: CHKDSK /V|FIND"file name" where the file name must be in uppercase letters.
Method 2: DIR /S file name
32. Real-time control of printer line feed or page feed
ECHO+>PRN (line feed)
ECHO^L>PRN (page feed)
33. Making the computer make a sound at the DOS command line
ECHO ^G
34. Automatic response to DOS command questions
For example:
ECHO Y|DEL C:
ECHO N|CHKDSK C:/F
35. Making the ECHO command display an empty line
When the ECHO command is directly followed by a space character, ECHO will display the current information echo status (ON or OFF), and not directly echo an empty line to the screen. In fact, the following some very simple command formats can all make the ECHO command display an empty line:
ECHO ECHO, ECHO; ECHO+
ECHO[ ECHO] ECHO/ ECHO\par
36. Using the ECHO command to feed a carriage return to an interactive DOS command
For example:
ECHO+|DATE|FIND"Current date"
ECHO+|TIME|FIND"Current time"
This skill can be used in AUTOEXEC.BAT, so that the current date and time information is directly displayed after each boot, and you don't need to press the Enter key to continue.
37. Boot time black box
Sometimes it is necessary to record the date and time of each use of the computer to strengthen the computer usage management. You can use the above skills. Just add the following commands in the AUTOEXEC.BAT file:
ECHO+|DATE>>ABC
ECHO+|TIME>>ABC
In this way, after each computer startup, the date and time will be automatically recorded in file ABC, and the command TYPE ABC can be executed to view the previous boot date and time.
38. Automatically counting the running time of commands or files
The following is a timer TIMETEST.BAT, which realizes the automatic counting of the running time of commands or files:
@ECHO OFF
TIME 0
COMMAND /C %1 %2 %3 %4
ECHO %1 %2 %3 %4 running time is:
ECHO+|TIME|FIND"time is"
@ECHO ON
For example, test the running time of AUTOEXEC.BAT:
C>TIMETEST AUTOEXEC.BAT ┆
The running time of AUTOEXEC.BAT is:
Current time is 0:00:03 49
It shows that AUTOEXEC.BAT ran for 3.49 seconds.
39. Skipping or stepping through the CONFIG.SYS and AUTOEXEC.BAT files
Method 1: Start the computer, when the screen shows "Starting MS-DOS…", press the F5 key or the SHIFT key, and DOS will skip the two files CONFIG.SYS and AUTOEXEC.BAT, and start the machine with the basic environment configuration of the system operation.
Method 2: When the above prompt appears, press the F8 key, and answer Y or N one by one through the keyboard to select the execution command.
Method 3: Add a "?" sign in the command of the CONFIG.SYS file. For example, DOS?=UMS, so when this command is executed, a selection prompt [Y, N]? will appear, allowing you to choose whether to load this command.
40. Can the two-second time of waiting to press F8 or F5 when DOS starts be omitted?
Yes. The method is to add the statement SWITCHES=/F at the head of the CONFIG SYS file. After that, the previous function can be realized in the same way. The method is to press the F8 or F5 key before the "Starting MS-DOS…" appears.
41. Step-by-step execution of a batch file
COMMAND/Y/C (batch file name)
The switch /Y tells DOS to pause before executing each line and ask the user whether to execute with [Y, N]?.
42. Quickly obtaining help information for DOS commands
Method 1: FAST HELP command name
Method 2: command name/?
Method 3: command name/H
43. Conveniently changing the subdirectory name
The following MOVE command can change the C: directory to C::
MOVE C: C:
44. When to use the MOVE command to move files?
The biggest feature of the MOVE command is that multiple files to be moved can be listed in one command line, and the files can be separated by ",". For example, move all executable files in the current directory into the directory:
MOVE *.COM,*.EXE,*.BAT
45. Using the MOVE command to simply encrypt or decrypt subdirectories
Encryption: For example, to simply encrypt the C: directory with a half-Chinese character, the executable command can be:
MOVE C: C(half-Chinese character)
Decryption: Conversely, the MOVE command combined with the wildcard * or? can be used to change the unrecognizable directory name to another name to achieve the decryption purpose.
46. Quickly entering a deep subdirectory
The SUBST command can be used to set the drive identifier to replace the deep subdirectory path, making it very convenient to enter the deep subdirectory. For example, the following command can simulate the subdirectory C: as drive M:
SUBST M: C:
In this way, in any directory, as long as the current drive is changed to M, you can enter the PRG subdirectory.
47. How to cancel the drive letter set by SUBST?
For example, to cancel the M drive in the above example, just execute the command SUBST M:/D.
48. The MD command to create and enter a new directory
The MD command in DOS can only create subdirectories. After creating, use the CD command to enter. In fact, you can use:
DOSKEY MD=MD $1 $T CD $1
Redefine the MD command. After that, when using MD, the creation of the directory and the entry into the directory are completed synchronously.
49. Exclusion method file listing
The DIR command supports wildcards * and? to replace other characters, but it does not provide the corresponding function of excluding characters. However, using the /V parameter in the FIND command, the exclusion method listing can be easily realized. The following command can list all files except.BAK files and subdirectories:
DIR|FIND/V"BAK"|FIND/V"<DIR>"
50. Difference between > and >>
DIR>DIRLIST: If the DIRLIST file exists, its file content will be cleared, and the new content will be input into the file.
DIR>>DIRLIST: If the DIRLIST file exists, the output data will be appended to the end of this file.
When the DIRLIST file does not exist, the two are equivalent.
51. Quickly adding a search path
PATH=%PATH%;%1
52. For data files and text files generated by word processing programs and other non-executable files, establish an automatic search path.
The APPEND command can add a group of specified directories to the logical extension of the current directory, so that these files can be opened without specifying the path. Multiple directories can be placed after APPEND, as long as they are separated by ";", for example:
APPEND C:;C:;C:;C:;
53. Hiding the directory name
Since the ATTRIB command can change the attribute of a directory, the directory name can be hidden by using this command. For example, hide the directory C::
ATTRIB +H C:
54. Quickly deleting the directory tree
The DELTREE command can quickly delete the specified directory, regardless of how many subdirectories and directories are in the directory and what the attributes of the files are. For example: DELTREE C:
55. Preventing accidental deletion of files
The DEL command is a dangerous command. You can redefine it with the following command to make it have a confirmation prompt when deleting files:
DOSKEY DEL=DEL $1/P
56. If some files are accidentally deleted, is there any way to recover them in time?
The UNDELETE command can be used to recover deleted files. The following command can recover the deleted files in the current directory:
UNDELETE *.*/ALL
The first character of the file name recovered by this command becomes #, and the original file name can be changed with the REN command.
57. When deleting multiple files with no common characteristics in the file name, since it is difficult to use wildcards, they can only be deleted one by one, which is more troublesome. Is there any other convenient method?
Yes. Use the DEL *.* /P command, the system will list all files in the specified directory one by one, ask the user whether to delete, answer Y for the file to be deleted, otherwise answer N.
58. One method of encrypting the file name
Add ASCII character 255 at the end of the file name to be encrypted. The method is to press the ALT key after entering the file name, and then enter 255. In this way, when the DIR command lists the file, this character is not displayed, that is, it cannot be seen from the file name that any change has occurred, which plays a certain encryption role.
59. Recalling used commands
After executing the DOSKEY command, the commands entered by the user are stored. Later, if you want to recall the used commands, you can use the "↑" or "↓" keys to search forward and backward one by one at any time.
60. Prohibiting illegal access to a certain drive
Add the following two commands in the AUTOEXEC.BAT file to prohibit illegal access to drive D. When entering D:, the screen will be closed, and only those who know the password ZM can enter drive D:
DOSKEY D:=ECHO OFF
DOSKEY ZM=D:
61. Preventing others from accidentally formatting drive C
To protect drive C and prevent others from formatting it, the FORMAT command can be redefined with DOSKEY. For example:
DOSDEY FORMAT=You can not format C:!
In this way, when others use FORMAT, the prompt Yor can not format C:! will appear, so that drive C is protected. If you want to use FORMAT yourself, restore it with the following command:
DOSKEY FORMAT=
62. Checking the screen status and obtaining a report on the display characters and lines of the screen
MODE CON
63. Setting the number of characters per line and the number of lines per screen of the screen
For example:
MODE CON COLS=80 LINES=25
64. Improving the response speed of the keyboard
MODE CON:RATE=32 DELAY=1
65. If you don't like the default setting of the Num Lock key when the system starts, what should you do?
Add the NUMLOCK command in the CONFIG SYS file, and specify the state of the NUMLOCK key when the system starts according to your preference:
NUMLOCK=ON(or OFF)
66. Simple keyboard lock
When you are using the computer and only leave for a while and don't want to shut down, in order to prevent others from using it casually, you can compile a simple keyboard lock LOCK BAT program (the content is as follows):
@ECHO OFF
CLS
CHOICE/C:* /N
After running, it is like a dead machine. The "*" is the key of the keyboard lock, and those who don't know it can't decipher it.
67. Selective display of files
Suppose there are 10 files such as MY1 TXT, MY2 TXT,..., MY10.TXT. Now, if you want to display 4 files among them: MY2.TXT, MY3.TXT, MY6.TXT, and MY9.TXT, you can use the following command to realize it very conveniently:
FOR %A IN(2369)DO TYPE MY%A.TXT
68. Deleting mistakenly copied files
When using the COPY A:*.* command to copy all files on drive A to a subdirectory of the hard disk, but accidentally copied them to the root directory of the hard disk. If a large number of mistakenly copied files are involved and the file names have no characteristics, at this time, if you want to delete these files, the usual practice is to use the PCTOOLS tool software for selective deletion, which is more troublesome. Using the FOR command is much simpler:
A>FOR %A IN(*.*)DO DEL C:%A
69. Since the FIND command cannot accept wildcards, if you want to find a certain string in several text files, you can only use the FIND command for each file in turn, which is obviously very time-consuming. Is there no shortcut?
Yes. Use the FOR command in combination with the FIND command. The format is:
FOR%A IN(文件组)DO FIND"string"%A
70. The FOR command cannot be nested. Is there a way to realize FOR loop nesting?
Yes. You can use COMMAND.COM as the command in the first-level loop to let it execute another FOR loop command. For example, the following command can display 12 lines of "Welcome you" on the screen: FOR %A IN(123)DO COMMAND/C FOR %B IN(1234)DO ECHO Welcome you
71. The role of double colons :: in the comment line
At the beginning of the DOS batch file, the REM comment command is often used to add a program header. For example, suppose there is a batch file named TEST.BAT, which uses a text file name as an input parameter. When explaining its usage at the beginning, a comment line using < and > and parentheses is used, that is:
REM TEST<filename>
When the program executes this command, DOS will display the "File not found" information because it thinks that filename is a source file for a redirect input operation, and it cannot be found in the current directory. How to solve this problem?
It's very simple. Just change REM to double colon "::", that is:
::TEST<filename>
72. IF ERRORLEVEL in batch processing
When using the IF ERRORLEVEL command in a batch file, be careful because DOS considers any exit status value greater than or equal to the set value to be equivalent. Usually, the exit status value should be tested in descending order. For example:
IF ERRORLEVEL 2 ECHO TWO
IF ERRORLEVEL 1 ECHO ONE
IF ERRORLEVEL 0 ECHO ZERO
73. Can the exit status value be tested in ascending order?
Yes. But it should be judged in combination with the form of IF NOT. For example, the commands in example 72 should be changed to:
IF ERRORLEVEL 0 IF NOT ERRORLEVEL 1 ECHO ZERO
IF ERRORLEVEL 1 IF NOT ERRORLEVEL 2 ECHO ONE
IF ERRORLEVEL 2 IF NOT ERRORLEVEL 3 ECHO TWO
74. Using the @ symbol in batch files to prohibit commands from being displayed on the screen
Since DOS displays each command on the screen before executing it, even if you set the ECHO command to OFF, it will itself appear on the screen. To suppress its display, you can add the @ symbol before the ECHO command line: @ ECHO OFF
75. Counting the number of lines of the source program
Suppose the source program is named ZM.PRG. The following FIND command can conveniently count how many lines it has:
FIND/V/C" "ZM.PRG
76. Sorting text files
The SORT command is often used to sort and display some text line-based files. For example, display a list file containing phone numbers according to the first letter of the name. Command format:
SORT[/R][/+n]<filename1>filename2
Among them, /R means reverse sorting, /+n means starting from which line to sort, filename1 is the source file name, and filename2 is the sorted file name.
77. Using PROMPT to set a meaningful prompt
The PROMPT command is used to set a new DOS system prompt. For example:
PROMPT $P$G Get the current drive name and directory as the prompt
PROMPT $D$G Get the current system date as the prompt.
78. How to set the screen color?
Suppose ANSI.SYS has been installed in memory. The following command can set the screen to white background and red characters:
PROMPT $E[31;47m
79. Displaying date and time information at the selected position on the screen
Combining the screen and cursor control functions of ANSI SYS with the function of setting the DOS command prompt of PROMPT, special information can be displayed at the selected position on the screen. For example, add the following command line in AUTOEXEC BAT, and the date and time information can be moved to the lower right corner of the screen:
PROMPT $E[S $E[25;52H $D$T $E[u $P$G
80. Editing the last command with the F2 key
The F1 or F3 function key can be used to copy the last command. Similarly, the F2 key can get part of the last command. When the F2 key is pressed, DOS will copy the content of the last command to the character typed after pressing the F2 key (excluding).
For example, the following command is typed:
C>DIR.COM<enter>
Press the F2 key and the M key, and you can get:
C>DIR
At this time, press the INS insert key again, enter R, and then press the F3 key to copy the remaining part of the last command, and get the correct command:
C>DIR.COM
81. Editing the last command with the F4 key
When the F4 key is pressed, DOS copies the last command starting from the letter pressed after the F4 key. For example, the last command is:
C>DIR[enter]
Press the F4 key, then enter F, and then press F3, DOS will display the FORMAT command:
C>FORMAT
82. Using the SHELL command to change the size of the environment space
Increase the environment variable space to 1KB. You can add the command line in the CONFIG.SYS file:
SHELL=C:.COM/P/E:1024
83. Referring to environment variables in batch files
Batch files can refer to environment variables defined on the system. The specific method is to put a percent sign "%" before and after the environment variable name. For example, to display the content of the environment variable PATH in the batch file, you can add the command line:
ECHO %PATH%
84. Viewing a single environment variable
If you often use environment variables, when using the SET command to display all currently allocated environment variables, the list may be very long and the screen may be messy. For convenience, you can use the following batch file VIEWENV.BAT to directly display a single environment variable on the command line:
SET|FIND/I "%1"
For example, to view the content of COMSPEC, just execute:
VIEWENV COMSPEC
85. Making a DOS system disk
Method 1: FORMAT A:/S
Method 2: SYS A:
86. Regularly organizing the hard disk
Specific steps:
· Delete unnecessary files on the hard disk
· Run CHKDSK/F
· Run DEFRAG
87. Understanding the types of memory
· Conventional memory: 0-640KB
· Upper memory area (UMA): 640KB-1MB
· Extended memory: extends upward from 1MB
· High memory area (HMA): an extended memory area slightly less than 64KB above 1MB
· Expanded memory
88. Moving DOS to the high memory area
To enable users to have a larger available basic memory, the following command can be added in the CONFIG.SYS file to load HIMEM.SYS and move DOS to the high memory area (HMA):
DEVICE=C:.SYS
DOS=HIGH
89. Loading device drivers and memory-resident programs into upper memory (UMB)
Add the command in the CONFIG.SYS file:
DEVICE=C:.EXE NOEMS
DOS=UMB
90. Loading programs into the high memory area
The method to load the program into HMA is to add a /U switch on the command line. For example:
MOUSE/U
91. Use of upper memory
To make the program reside in upper memory, use LOADHIGH (or LH)<program name> that is, for example:
LH MOUSE
92. How to display the memory usage of a specific program?
MEM/M module
Among them, module represents the specific program file name, without the extension.
93. Using Memmaker to automatically optimize memory
Execute the MEMMAKER/BATCH command, and MEMMAKER will automatically make the optimal settings for the CONFIG.SYS and AUTOEXEC.BAT files. After that, execute MEM/C/P to observe the memory allocation situation, and you will find that the main memory has become larger.
94. If you are not satisfied with the optimization settings of MEMMAKER, what should you do?
It's very simple. Just execute MEMMAKER/UNDO to restore your original configuration.
95. Use of disk cache SMARTDRV
To create a disk cache with 256K (default value), you can add the command line in the AUTOEXEC.BAT file:
C:
Since SMARTDRV is built in extended memory, you must also add the command line in the CONFIG.SYS file:
DEVICE=C:.SYS
96. When you shut down the computer or restart it, if you want to make sure that all information in the cache is written to the hard disk, you should type the command at the system prompt:
SMARTDRV/C
97. Skipping the magnetic medium scan of SCANDISK
When running SCANDISK, the magnetic medium scan takes a long time. In fact, using SCANDISK/CHECKONLY can skip it.
98. Correct use of the LOADFIX command
During the optimization process, a few programs cannot run correctly in the low 64KB of the 640KB conventional memory. At this time, the LOADFIX command can be used to let the executable program (such as ZMPROG.EXE) run in the memory above the low 64KB. The method is to add LOADFIX before the application program to be run:
LOADFIX ZMPROG
99. When to use a virtual disk (also called RAM disk)?
The RAM disk can significantly improve the access speed of disk files, but it will lose data when the power is off or restarted. Therefore, special care should be taken when using the RAM disk. The RAM disk is worth using on a system without a hard disk; it can also be used when you need to store larger temporary files or copy programs; when your system is equipped with a CD-ROM, you can copy the files and data on the CD-ROM disk into the RAM disk before starting work, which can significantly improve efficiency.
100. Installation of the virtual disk
The RAMDRIVE.SYS provided by DOS is a virtual disk driver. You can install it into the memory, let it use extended memory or expanded memory, and generate a RAM disk of the specified size. For example, add the following command in CONFIG.SYS, and a 1MB RAM disk can be generated in the extended memory:
DEVICE=C:.SYS 1024/E
Recent Ratings for This Post
( 20 in total)
Click for details
| Rater | Score | Time |
|---|---|---|
| 雨露 | +20 | 2006-10-21 10:19 |
| — | +1 | 2006-11-15 02:00 |
| redtek | +5 | 2006-11-18 00:37 |
| wydos | +2 | 2006-11-21 09:11 |
| seazy | +2 | 2006-12-03 10:15 |
| namejm | +4 | 2006-12-12 23:30 |
| sleet1986 | +1 | 2007-01-11 21:57 |
| technique | +1 | 2007-03-23 14:25 |
| uforange | +2 | 2007-05-11 20:58 |
| luowei144 | +2 | 2007-05-22 22:23 |
| dthao | +2 | 2007-09-27 21:32 |
| lxlqldljw | +1 | 2008-02-27 11:13 |
| wang6542975 | +2 | 2008-06-02 17:21 |
| taotaomike | +1 | 2008-07-26 21:06 |
| tinlin | +2 | 2008-08-21 12:29 |
| konkoo | +1 | 2009-06-26 03:10 |
| zzz19760225 | +1 | 2016-08-08 01:41 |
| briar | +40 | 2017-11-11 07:24 |
| realhigher | +1 | 2023-11-03 23:35 |
| gooooood | +1 | 2025-10-26 15:46 |

