China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-25 09:00
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Repost: Clever Use of DOSKey View 2,283 Replies 8
Original Poster Posted 2002-10-25 00:00 ·  中国 广东 佛山 禅城区 电信
元老会员
★★★★
Credits 5,170
Posts 1,637
Joined 2002-10-16 00:00
23-year member
UID 8
Gender Male
From 广东佛山
Status Offline
Clever Use of DOSKey

DOSKey is a commonly used memory-resident program under MS-DOS. Its main functions are: recording typed commands in a memory buffer and turning command sequences into macros.
DOSKey is usually added to the batch file AUTOEXEC.BAT, that is, add DOSKey or LH DOSKey to the command line in AUTOEXEC.BAT. You can also type DOSKey or LH DOSKey directly under MS-DOS to start it. After DOSKey is installed, you can conveniently and quickly find, use, and modify commands typed previously. Below is a brief introduction to several ways to use DOSKey:
First: Find, display, and edit a DOS command:
For commands just typed, you can use the ↑ or PageUP and ↓ or PageDown keys to find them; for commands typed earlier, you can use F7 to display the command list, then use F9 to enter the number of the command in the list. While searching, DOSKey allows you to edit and modify the current command line by moving the cursor with the ← and → keys. During editing you can also use the Insert key to switch between character insert and overwrite modes.
Second: Enter multiple commands at the same time:
Using DOSKey, you can type multiple commands on the same command line, separating each command with "Ctrl + T". The command format is:
DOSKey command1 "Ctrl + T" command2 "Ctrl + T" command3
For example, at the DOS prompt type:
C:\>cd mydocu~1 "Ctrl + T" dir *.doc/w "Ctrl + T" dir *.xls
After pressing Enter, the three commands entered will be displayed and executed in sequence.
Third: Create a batch file:
Everyone knows that batch files can be created with copy con:, Edit, and other methods. Now let me tell everyone that for some not-too-long batch files, they can also be created entirely with DOSKey. This method uses DOSKey's /history command to input the records in the list into a BAT file.
First, press "Alt + F7" to clear the record buffer in memory; then type the required batch contents. For example, at the DOS prompt type:
C:\>CLS
C:\>CD \WINDOWS\TEMP
C:\WINDOWS\TEMP>SUBST B: .
C:\WINDOWS\TEMP>CD..
C:\WINDOWS>DOSKey /history > setb.bat
This saves the above commands in setb.bat. Finally, use a text file editor (such as: EDIT) to delete the last line, "DOSKey /history >setb.bat". After that, as long as you run setb.bat, you can create a virtual B drive.
Fourth: Use DOSKey to create macros:
With DOSKey, you can create some commonly used groups of DOS commands as a macro.
The command format is:
DOSKey name(macro name)=command1 $t command2 $t etc.,(command group)
Each command in the command group is separated with $t. For example, type:
C:\>DOSKey aut=dir *.exe/p $t dir *.com/p $t dir *.bat/p
Press Enter. Later, you only need to type aut to display all executable files in the current directory.
Macros can also use replaceable parameters like batch files; the parameter is $n, where n=1~9. For example: C:\>dos
key hmy=md $1$t cd $1
This macro replaces the two DOS commands md and cd. You only need to use hmy Content(directory name) to create a directory and enter that directory at the same time.
Since macros are stored in memory, they will be lost after shutting down. However, you can add these commonly used macros to the command line in AUTOEXEC.BAT, which will make them very convenient to use in the future.
DOSKey also has many options and command editing keys. If you need detailed information, you can type DOSKey/help or DOSKey/? to query.
我的网志
http://hzmys.blog.163.com/
我的网盘
firststep.qjwm.com
fsmys.ys168.com
ssmys.ys168.com
www.brsbox.com/fsmys
www.brsbox.com/ssmys
www.brsbox.com/ccdos
Floor 2 Posted 2002-10-26 00:00 ·  中国 陕西 西安 电信
初级用户
★★
孤胆枪手
Credits 688
Posts 148
Joined 2002-10-26 00:00
23-year member
UID 63
Gender Male
From 陕西
Status Offline
我:╭∩╮(︶︿︶)╭∩╮。靠!!!
Floor 3 Posted 2002-10-26 00:00 ·  加拿大 安大略省 多伦多
初级用户
Credits 107
Posts 3
Joined 2002-10-26 00:00
23-year member
UID 64
Gender Male
Status Offline
Good! Impressive, such a tiny doskey actually has so many uses.
Floor 4 Posted 2004-12-06 00:00 ·  中国 湖南 长沙 电信
初级用户
Credits 122
Posts 4
Joined 2004-05-05 00:00
22-year member
UID 23814
Gender Male
Status Offline
Although this is a very old post, I still think it was really worthwhile; after reading it I learned quite a lot
Floor 5 Posted 2004-12-19 00:00 ·  中国 山东 济宁 电信
中级用户
★★★
痴迷DOS者
Credits 456
Posts 570
Joined 2004-10-09 00:00
21-year member
UID 32281
Gender Male
Status Offline

DOS不是万能的,没有DOS是万万不能的
自古系统谁无死?留取胆清照汗青!uploadImages/20035317345478982.png
Floor 6 Posted 2005-10-20 21:09 ·  中国 江苏 苏州 电信
初级用户
★★
Credits 125
Posts 72
Joined 2005-09-13 06:10
20-year member
UID 42467
Status Offline
Good! Impressive, such a tiny doskey actually has so many uses.
Floor 7 Posted 2005-10-31 17:33 ·  中国 山西 临汾 联通
中级用户
★★
Credits 241
Posts 131
Joined 2005-09-28 19:01
20-year member
UID 42920
Gender Male
Status Offline
Actually DOSKEY can also have many uses under WIN's GUI. Its functions are very powerful; it mainly depends on how you use it!
房东说:这娃是个好孩子!
Floor 8 Posted 2005-11-06 10:28 ·  中国 陕西 西安 电信
新手上路
Credits 18
Posts 9
Joined 2005-11-04 19:43
20-year member
UID 44596
Gender Male
Status Offline
Really impressive! I want to learn too! I don't know much about DOS, but I want to learn. Please give me more guidance! Thanks!
Floor 9 Posted 2005-11-06 20:34 ·  中国 广东 广州 白云区 电信
荣誉版主
★★★
Credits 718
Posts 313
Joined 2005-09-26 00:00
20-year member
UID 42844
Gender Male
Status Offline
I’ll add a few examples:

1。Use DOS macros to extend the functions of the DIR and CHKDSK commands:
DOSKEY DIRNAME =DIR /ON /P (sort the current directory by name)

DOSKEY DIREXNAME= DIR /OEN /P (sort the current directory by extension)

DOSKEY CHKDSKM =FOR %I IN (C:D:E:F:) DO CHKDSK %I (automatically run the CHKDSK command on multiple drives)

2,The CLUSTER macro displays the cluster size:
DOSKEY CLUSTER =CHKDSK $b | FIND “EACH”

3,Each time DEL is used, the user must confirm again:
DOSKEY DEL =DEL $1 /P

PS:
To create macros, DOSKEY must first be loaded into memory.
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
lovyou3344 +1 2010-11-21 23:24
Forum Jump: