最近有一些用户询问论坛DOS命令提示符界面的基本使用方法,比如询问如何在命令行下回复帖子、短消息等,鉴于之前有关DOS命令提示符界面的介绍性内容分散在论坛一些不同的帖子中,而且命令提示符界面本身的帮助原为英文(3.4版本以后已支持多语言,包括简体和繁体中文),现在我将把DOS命令提示符界面中各命令详细的中文使用方法,以及常见操作问题进行汇总,整理成本帖(相当于用户指南)。论坛DOS命令提示符界面的地址如下,大家可以一边继续阅读一边使用:
http://www.cn-dos.net/forum/cmdprmt.php
==
目录==
一、简要介绍
二、功能概述
三:常见操作
四、命令详解
五、开发说明
第一部分:简要介绍
论坛DOS命令提示符界面是中国DOS联盟论坛的Web命令行版本。它支持目前各种常见浏览器,包括Internet Explorer 5.5+、Mozilla Firefox 1.5+、Opera 9+,或者与它们完全兼容的浏览器。现在论坛DOS命令提示符已可以完成论坛GUI版可以完成的大多数基本功能,比如用户登录/登出、查看用户状态或资料、浏览帖子、编辑帖子、搜索帖子、订阅主题、收发短消息等等。除此之外,它还具有许多命令行所特有的功能,包括自由编写批处理文件等。它的使用方法和纯DOS及Windows下的CMD命令提示符十分相似,综合了这两种环境的主要优点,并结合了一些论坛特色,尤其是作为以讨论DOS为主的中国DOS联盟论坛的特色。通过命令行界面,用户可以通过一条命令或一系列命令来完成所想要的功能,包括简单和复杂的功能,而这些通常比使用GUI界面要高效和快捷得多。这也正是许多人研究和学习命令行、批处理的主要原因所在。同时,论坛DOS命令提示符支持多语言界面功能(包括简体中文、繁体中文和英文),默认起始语言为用户所用的浏览器的默认语言,并可以手工指定或随时在命令行上切换界面显示的语言(详见CHCP命令),以给予大家一个熟悉的语言环境。
第二部分:功能概述
论坛DOS命令提示符界面支持DOS/CMD环境下的大多数常见命令,以及一部分具有论坛特色的命令,可以用这些命令来直接访问和操作论坛。多数命令支持一些参数或开关,用户可以随时在命令行上输入HELP命令来查看命令列表和说明,以及用“HELP 命令名”或“命令名 /?”的形式来查看有关该命令的更多帮助。论坛DOS命令提示符界面所支持的命令包括两大类,一类为不需要提交到服务器的命令(有点类似于DOS的内部命令),另一类为需要提交到服务器的命令(有点类似于DOS的外部命令)。前者输入后将直接被执行,后者则将自动提交到服务器来执行,比如显示帖子、编辑帖子、收发短消息等。后者如果正常执行,返回的ERRORLEVEL值为0,否则返回的ERRORLEVEL值为1。如果接收的服务器响应不正确,则返回的ERRORLEVEL值为2。
论坛DOS命令提示符界面所用的许多概念和命令与DOS/CMD下的对应内容十分类似。DOS命令提示符界面中的文件根据其所处的文件系统相当于论坛中的主题、帖子,以及短消息等,目录相当于论坛版块,驱动器则相当于论坛分类及收件箱/发件箱等。里面的命令与DOS/CMD下的功能也十分类似,比如DIR命令可以查看文件和目录(帖子、版块、短消息等);DEL命令可以删除文件;REN命令可以重命名文件;TYPE和MORE命令可以显示文件(主题、帖子、短消息)的内容,其中MORE命令每显示主题中的一个帖子的内容后将提示按键继续以显示下一个帖子的内容,尤其在主题中帖子较多时可以大大便于帖子的阅读;EDIT命令可以发新主题、回复帖子,以及编辑帖子内容,比如EDIT C:\1命令表示C:\1这个版块发一个新主题,EDIT C:\1\2表示回复C:\1\2这个主题,而C:\1\2 3则表示编辑C:\1\2这个主题中的第3个回帖(其中3为帖子号,如果为0表示主题帖,1表示第1个回帖,以此类推,当为负数时则从最后一个帖子开始数起;而TYPE、MORE和FIND命令也可选地支持这种用法);NET SEND命令可以发送/回复短消息等等。另外,对于用户订阅的文件(用NET FILE命令),可以用类似~1的形式对文件实现更快速访问。更详细信息请见命令帮助以及下面的命令详解。
与加载了DOSKEY的DOS下以及CMD环境下类似,论坛DOS命令提示符支持命令行历史的功能,用户可以在随时命令行上按光标键或PageUp/PageDown键来编辑或重新调用以前输入过的命令,以大大方便命令行操作。使用HISTORY命令可以查看命令行历史。
论坛DOS命令提示符界面启动后的默认盘符为A(其它盘符则分别代表不同的版块或特殊功能,如C盘代表论坛站务区,D盘代表DOS技术区,G盘代表收件箱等,可以用DIR命令看到),并将自动设置一些环境变量,如%AUTOSUB%、%CODEPAGE%、%DIRCMD%、%OS%、%PROMPT%、%USERNAME%,分别代表是否自动订阅编辑过的文件(默认为1)、当前代码页(默认为936,即简体中文,可用CHCP 437命令改为英文)、DIR命令预先设定的开关(默认为/P /V,可自行修改)、用户所用的操作系统(如Windows、POSIX等)、提示符(默认为$P$G,可自行修改)、用户名(如果已经登录)。此外,当用户未手工设置%CD%、%DATE%、%TIME%、%RANDOM%、%ERRORLEVEL%这些环境变量时,它们分别代表当前路径、当前日期、当前时间、一个随机整数、当前ERRORLEVEL值,与CMD下一致。
许多用户喜欢个性化的环境,比如启动时自动选用自己喜欢的颜色、字体等等。论坛DOS命令提示符支持将命令(可以是除EDIT外的任何命令)存入A:\AUTOEXEC.BAT文件,这样每次启动时这些命令将自动运行。AUTOEXEC.BAT是自启动批处理文件,和DOS下类似,每次启动时都会自动运行。论坛DOS命令提示符界面中的AUTOEXEC.BAT文件是用户级的,不同的用户可以有不同的AUTOEXEC.BAT文件,用户只要登录即可使用。通过对它的合适修改(用EDIT命令),比如修改相应的环境变量、字体、行距、颜色、提示符、窗口标题等,用户可以达到个性化环境的目的。不仅如此,由于AUTOEXEC.BAT文件中的内容不会消失,利用它还可以完成类似收藏夹等功能。以下是一个简单的AUTOEXEC.BAT文件的例子:
@echo off
break on
rem 设置环境变量:
set dircmd=/a/p
set prompt=$t-$p$g
...
goto end
:end
echo 以下将修改字体、颜色和标题,可按Ctrl+C键取消
pause
if %os%#==Windows# font FixedSys
if %os%#==POSIX# font Terminal
font 10%%
color 06
title 我的DOS提示符
echo 开始运行..
除AUTOEXEC.BAT文件外,用户还可以在A盘上自由建立和编辑其它文件,相当于用户的个人文件存储空间(不同的用户可以建立不同的文件)。例如可以使用EDIT A:\HELLO.TXT命令在A盘上建立HELLO.TXT文件(如果已经存在将修改原有的文件),同时可以用其它命令来操作这些文件(和DOS/CMD下的命令相同,例如TYPE/MORE显示文件内容、DEL删除文件、REN重命名文件,等等)。对于批处理文件,用户可以直接像DOS/CMD下那样执行,并可使用诸如%0、%1、%2这样的可替换参数。
第三部分:常见操作
为了方便大家的快速入门和使用,下面列出一些常见操作的使用方法:
1:切换界面语言
可使用CHCP命令来切换当前语言代码页。例如CHCP 437将语言代码页切换为437(英文)、CHCP 936将语言代码页切换为936(简体中文)、CHCP 950将语言代码页切换为950(繁体中文)。
2:自定义界面
可使用FONT、COLOR、TITLE、PROMPT等一系列命令来定义命令提示符的界面,如更改字体、行距、颜色、窗口标题、提示符等。详见这些命令的使用说明。
3:查看帮助
所有命令均有相关的使用帮助,可在命令名后加上/?开关,或使用HELP 的形式来查看。如果直接输入HELP命令将列出所有命令。帮助信息显示的语言为当前代码页的语言。
4:登录/登出论坛:
以指定的用户名登录论坛:
NET LOGON 用户名 密码 (或NET LOGIN 用户名 密码)
登出当前用户:
NET LOGOFF (或NET LOGOUT)
5:列出论坛版块:
可直接在A盘下输入DIR命令以查看论坛中的所有版块,如果已登录将同时列出用户文件。
如果要列出指定分类中的版块,可在DIR命令后加上相应驱动器,例如DIR C:等。
6:列出版块中的主题列表:
可在DIR命令后加上相应驱动器及路径,例如C:\1等。如果要列出所有的主题,可加上/A开关。DIR命令的开关可用DIR /?查看,也可以在%DIRCMD%环境变量中指定。
7:显示主题内容:
可使用TYPE或MORE命令查看指定主题中的内容,例如TYPE C:\1\2(如果当前目录为C:\1的话可直接输入TYPE 2)。同时可以指定主题中显示的起始帖子和显示数量,详见TYPE或MORE命令的参数。
8:发帖/回帖或编辑帖子
这些均可使用EDIT命令来完成,如EDIT C:\1将在C:\1目录(版块)下建立新主题,EDIT C:\1\2将回复C:\1\2这个文件(主题),EDIT C:\1\2 3将编辑C:\1\2这个主题中的第3个帖子等。如果要引用回复,可以使用/R开关,例如EDIT C:\1\2 3 /R将引用回复C:\1\2这个主题中的第3个帖子。有关EDIT的开关的更多信息可用EDIT /?查看。
除此之外,EDIT命令还可以建立和编辑A盘下的用户文件。详见EDIT命令的使用说明。
9:搜索帖子
可使用FIND命令来搜索帖子的主题和内容。例如FIND "hello" C:\1将搜索C:\1目录(版块)下所有含有"hello"这个字符串的帖子。FIND命令支持许多开关,比如查找指定用户所发的帖子、显示匹配的行数、显示匹配帖子的所有行、忽略大小写搜索、只在主题中搜索字符串等,详情可用FIND /?查看。
除此之外,FIND命令还可以搜索A盘下的用户文件,以及用户短消息中的内容。
10:收发短消息
可使用NET SEND命令来发送短消息,用法是NET SEND 用户名。用户的收件箱和发件箱均为独立的驱动器,可以在A盘的驱动器列表中看到(收件箱为G盘,发件箱为H盘)。可以用DIR、TYPE/MORE、FIND等命令在这些驱动器中列出、查看、搜索短消息等,也可以用"NET SEND RE 文件名"的形式来引用回复短消息。
11:订阅主题
可使用NET FILE命令来查看当前订阅的主题。如要加入或删除订阅的内容,可分别加上ADD或DEL参数。详见NET命令的用法。
12:查看用户信息和状态
可分别使用NET USER和NET VIEW命令来查看指定用户的个人信息和在线状态。如果不加用户名将分别显示自己的用户信息和所有用户的在线状态。
13:查看论坛信息
可分别使用NET GROUP和NET STATISTICS(可简写为NET STATS)来查看论坛的用户组信息和论坛统计数据。
14:操作用户文件
可以用DIR、TYPE/MORE、EDIT、FIND、REN、DEL等命令来操作A盘上的用户文件(相当于用户的个人文件存储空间)。同时,用户还可以直接建立或执行BAT批处理文件。
第四部分:命令详解
在DOS命令提示符界面中输入HELP命令时可以看到以下命令:
BREAK、CD/CHDIR、CHCP、CLS、CMD、COLOR、DATE、DEL/ERASE、DIR、ECHO、EDIT、EXIT、FIND、FONT、GOTO、HELP、HISTORY、IF、MORE、NET、PAUSE、POPD、PROMPT、PUSHD、REM、REN/RENAME、SET、SHIFT、TIME、TITLE、TYPE、VER、VOL
可以在DOS命令提示符界面下使用“HELP 命令名”或“命令名 /?”的形式查看其帮助。这儿是这些命令的更详细说明:
BREAK
功能:设置或清除扩展的Ctrl+C检测。
用法:BREAK
说明:和DOS下类似,当BREAK为ON(默认值)的时候,用户可以在执行任何需要等待的命令、批处理文件中按Ctrl+C或Ctrl+Break命令来强行中断命令本身或批处理的执行。例如当执行DIR或PAUSE命令时按下Ctrl+C键将自动退回命令行,即使当DIR命令仍在发送时。相反,当BREAK为OFF时用户不能使用Ctrl+C或Ctrl+Break命令来强行中断命令本身或批处理的执行。另外,BREAK可以控制EDIT命令编辑文件内容时是否允许按Ctrl+C或Ctrl+Break键退出。
举例:BREAK (显示当前BREAK状态)
BREAK ON (设置扩展的Ctrl+C/Ctrl+Break检测)
BREAK OFF (清除扩展的Ctrl+C/Ctrl+Break检测)
CD(或CHDIR)
功能:显示和更改目录。
用法:CD
说明:和DOS/CMD下类似,此命令可以显示或修改当前路径。另外当参数只包括驱动器名的时候,此命令将进入指定驱动器,与SFTP下相同。CHDIR和CD命令的作用相同。
举例:CD (显示当前路径)
CD .. (进入父目录)
CD C:\1 (进入C:\1目录)
CHCP
功能:显示或设置活动代码页编号。
用法:CHCP
说明:和DOS/CMD下类似,此命令可以显示或修改当前的活动代码页。此命令可用于切换命令提示符所用的语言,包括简体中文(936)、繁体中文(950)和英文(437或850),和CMD下一致。默认起始代码页根据浏览器的默认语言来自动选项,如当浏览器的默认语言为简体中文时起始代码页为936(简体中文),而当默认语言为繁体中文时起始代码页为950(繁体中文),否则的话起始代码页将为437(英文)。不过也可以通过在URL上加上?cp=xxx参数(其中xxx是要指定的代码页,如437)来将起始代码页设为相应的代码页。
举例:CHCP (显示当前代码页)
CHCP 437 (将当前代码页和界面语言切换为英文)
CHCP 936 (将当前代码页和界面语言切换为简体中文)
CHCP 950 (将当前代码页和界面语言切换为繁体中文)
CLS
功能:清除屏幕。
用法:CLS
说明:和DOS/CMD下类似,此命令将清除屏幕上的内容。另外,也可以使用Ctrl+Del快捷键来达到同样的效果。
举例:CLS (清除屏幕)
CMD(或COMMAND)
功能:启动或刷新命令解释程序。
用法:CMD
说明:CMD命令在DOS命令提示符界面启动时自动调用,加上/P参数将自动执行A:\AUTOEXEC.BAT批处理文件中的命令。
举例:CMD /P (将执行A:\AUTOEXEC.BAT批处理文件中的命令)
COLOR
功能:设置命令提示符的颜色(前景和背景色)。
用法:COLOR
说明:和CMD下类似,COLOR命令的参数由两个16进制数字组成,分别设置DOS命令提示符界面的前景和背景色。如果不加参数的话将恢复默认值。
举例:COLOR 07 (或COLOR 7,将颜色设置为黑底白字,和COLOR默认值相同)
DATE
功能:显示当前日期。
用法:DATE
说明:此命令将显示当前日期。另外,当未手工设置%DATE%环境变量时,%DATE%将自动展开为当前日期,和CMD下一致。
举例:DATE (显示当前日期)
DEL(或ERASE)
功能:删除文件。
用法:DEL 文件名
说明:和DOS/CMD下类似,DIR命令用于删除文件。对于主题文件,用户必须有管理权限方可进行删除;对于短消息文件(即收件箱和发件箱中的内容),用户只需登录即可用此命令对其短消息进行清理。帖子号为0表示主题帖,1表示第一个回帖,以此类推。负数则表示从最后一个帖子开始数起。
举例:DEL C:\1\2 -1 (删除C:\1\2文件中的最后一个帖子)
DEL G:\3 (删除G盘上的3这个文件/短消息)
DIR
功能:显示目录内容。
用法:DIR 属性]] 属性]]
说明:和DOS/CMD下类似,DIR命令通常用于显示指定目录下的文件及其信息。可以用offset,amount来控制范围,如10,20表示从第10个文件开始,共显示20个文件,默认为0,22,即前22个文件,可以通过offset,amount参数或/A开关来调整。DIR命令支持以下开关:
/A:列出所有带有指定属性的文件。(而默认则只显示前22个文件)
/A开关的属性可以是(如果未指定则表示所有):
A 附件 C 关闭/锁定 D 驱动器/目录
G 精华 H 热门 N 新
O 普通 P 投票 T 置顶
/B:只显示文件名
/C:显示文件/目录的建立日期/时间(默认则为显示最后修改日期/时间)
/P:分屏显示(每显示25个文件后提示按Enter键继续,或者按ESC或Q键退出)
/S:也显示子目录下的内容
/V:视图定制模式。所有关于指定的项目的信息将被显示,如果可能的话。
/V开关支持的项目可以是(如果未指定则表示所有):
A 属性 D 日期/时间 I ID
N 名称/标题 P 发帖人/版主 R 记录
另外为了兼容性而保留了一个/W开关,但将被忽略。
/A和/V开关的属性可以随意结合,以显示相应的内容。开关和选项之间可以加上一个冒号间隔,也可以省略,比如/AFG和/A:FG的作用相同。使用/V开关可以显示文件/主题的属性、查看数、回复数、作者、发帖人,版块的文件及帖子总数、版主等信息。用户可使用/V开关的各种属性来自定义显示风格,比如可以不显示某些信息以节省屏幕空间等。其中,文件的属性可以是<DIR>(目录/版块)、<顶>(置顶帖)、<新>(新帖或新消息)、<精>(精华帖)、<票>(投票帖)、<锁>(关闭/锁定的帖子)、<热>(热门帖子)、<附>(带附件的帖子)。
如果在开关前加上-字符(如/-A、/-V等)则表示取消该开关。除在命令行上使用外,也可以在%DIRCMD%环境变量中来预先指定这些开关。%DIRCMD%的默认值为/P /V,可以用SET命令修改,或者在命令行下加上-字符(如/-V)来取消指定的开关。除%DIRCMD%的默认值外,这些均与DOS/CMD下一致。
举例:DIR A: /B (只显示A盘上的所有文件的名称)
DIR C:\1 /AHT /P (分屏显示C:\1下的所有置顶或热门文件/帖子)
DIR C:\1 20,30 (显示C:\1下的文件,从第20个文件开始,共显示30个文件)
DIR C: /A/S/-V (显示C盘上的所有文件,包括子目录下的内容,但不显示详细信息,如发帖人等)
ECHO
功能:显示文字,或者打开和关闭命令回显。
用法:ECHO 或 ECHO
说明:和DOS/CMD下类似,ECHO可用于显示指定的文字,也可用于显示或设置命令回显。当ECHO为ON的时候,系统将回显当前提示符和命令。当ECHO为OFF时则相反。通常在批处理文件中加入@ECHO OFF即可使系统不显示批处理文件中执行的命令。
举例:ECHO (显示当前ECHO状态)
ECHO 大家好!(显示“大家好!”)
ECHO. (显示一空行)
ECHO ON (打开命令回显)
ECHO OFF (关闭命令回显)
EDIT
功能:启动文件编辑器,以创建和编辑文件文件,可用于发帖、回帖、改帖等。
用法:EDIT 路径 | 文件名
说明:和DOS/CMD下类似,EDIT命令可用于编辑文件。用户必须登录以使用此命令。路径既可以是相对路径也可以是绝对路径。如果未指定文件名,则表示在指定路径下建立新文件(即发新主题),否则表示编辑该文件(包括回帖、改帖)。如果指定了帖子号的话,EDIT将打开主题中的相应帖子以让用户进行编辑(即编辑帖子),否则表示在主题中回帖。帖子号为0表示主题帖,1表示第一个回帖,以此类推。负数则表示从最后一个帖子开始数起。EDIT命令也可用于建立或修改A盘上的文件,例如A:\AUTOEXEC.BAT批处理文件。另外,如果%AUTOSUB%环境变量的值为正数时,编辑过的文件(主题)将自动被订阅。
EDIT命令支持以下开关:
/D:禁用 Discuz! 代码(默认为启用)。
/I:忽略帖子的积分和时间限制。
/R:在文件中引用回复帖子(如果未指定帖子号则默认为回复主题帖)。
/S:不使用个人签名(默认为使用)。
/T:编辑帖子时在帖子后自动附加编辑日期和时间。
/U:禁用 URL 识别(默认为启用)。
举例:EDIT A:\AUTOEXEC.BAT (编辑A:\AUTOEXEC.BAT文件)
EDIT C:\1 (在C:\1这个版块下发新主题)
EDIT C:\1\2 (在C:\1\2这个主题下回帖)
EDIT C:\1\2 1 /T (编辑C:\1\2这个主题下的第1个回帖,并在帖子后自动附加编辑日期和时间)
EDIT C:\1\2 2 /R (引用回复C:\1\2这个主题下的第2个回帖)
EDIT C:\1\2 -2 /S (编辑C:\1\2这个主题下的倒数第二个回帖,且不使用个人签名)
EXIT
功能:返回图形界面。
用法:EXIT
说明:此命令将返回论坛的图形界面。
举例:EXIT (返回图形界面)
FIND
功能:查找文件中的指定文字。
用法:FIND "字符串" 路径 | 文件名
说明:路径用于指定查找文件的范围,如果不指定文件名则将查找该路径中的所有文件,也可以用offset,amount来控制范围(和DIR命令的一样,如10,20表示从第10个文件开始,共查找20个文件;如不指定则表示所有文件)。如果指定了帖子号的话,FIND将只从文件(主题)中的指定帖子中查找,否则从主题中的所有帖子中进行查找。帖子号为0表示主题帖,1表示第一个回帖,以此类推。负数则表示从最后一个帖子开始数起。字符串即要查找的字符串,用引号括起来,里面可以有空格,默认将显示文件中所有匹配该字符串的行,但可以通过开关来进行调整(多数与DOS/CMD下的一致):
/A:显示带有指定字符串的帖子中的所有行
/I:忽略字符串的大小写
/C:仅显示文件中匹配该字符串的行数
/N:仅显示匹配该字符串的文件名
/S:仅在标题中搜索字符串
/U:显示指定用户发的帖子的内容(如帖子号为0表示仅查找并显示指定用户发的主题帖,默认则从主题帖和所有回复帖中寻找)
/V:仅显示不匹配该字符串的所有行。
举例:FIND "ECHO" A:\AUTOEXEC.BAT /V (查找并显示A:\AUTOEXEC.BAT文件中所有不含ECHO这个字符串的行)
FIND "hello" C:\1\2 /N (在C:\1\2文件中查找hello这个字符串,如果包含此字符串将显示这个文件名)
FIND "USER" C:\1 0 /U /I (在C:\1目录下查找所有由USER发的主题,并且不区分用户名的大小写)
FIND "HELLO" C:\8 0,20 4 /A/I/N (在C:\8目录下的前20个文件中,查找并显示包含HELLO这个字符串且为第4个回帖的所有帖子,并且不区分大小写)
FONT
功能:显示所有可用的字体,或更改当前字体。
用法:FONT LIST 或 FONT 或 FONT
说明:FONT LIST可显示所有可用的字体的列表,FONT 将更改当前字体。字体既可以是字体名也可以是它所对应的ID(即用FONT LIST命令所看到的ID),比如可用1代表Courier,2代表FixedSys(CMD下的默认字体)等等。FONT 则用于设置行距,其中数值的范围为0-100之间。
举例:FONT (显示当前字体)
FONT LIST (显示所有可用的字体)
FONT FixedSys (将当前字体更改为FixedSys,与FONT 2的作用相同)
FONT 50% (将行距设置为50%)
GOTO:
功能:在批处理中跳转到一个指定的标号上。
用法:GOTO 标号
说明:和DOS/CMD下类似,GOTO命令将使批处理文件跳转到提定的标号上。另外如果使用GOTO :EOF将自动跳转到批处理文件结束,和CMD下一致。
举例:GOTO next (假设批处理文件中已有:next这一行,GOTO next将跳转到此行)
HELP
功能:提供命令的帮助信息。
用法:HELP
说明:和CMD下类似,HELP命令将显示指定命令的帮助,或者也可以使用更简单的“命令名 /?”这样的形式。如果不加参数的话HELP命令将显示所有命令的列表。
举例:HELP (显示命令列表)
HELP DIR (显示DIR命令的帮助,与DIR /?作用相同)
HISTORY
功能:显示命令行历史。
用法:HISTORY
说明:此命令将显示用户在DOS命令提示符界面中输入的命令。可以使用方向键和PageUp、PageDown来调用之前输入的命令,与加载了DOSKEY的DOS下和CMD下一致。
举例:HISTORY (显示命令行历史)
IF
功能:完成条件性处理。
用法:IF ERRORLEVEL 数值 命令
IF 字符串1==字符串2 命令
IF EXIST 文件名 命令
说明:和DOS/CMD下类似,IF命令用于条件判断,包括判断当前ERRORLEVEL值是否大于或等于指定数值、指定字符串是否相等、指定文件是否存在。NOT表示否定。另外,IF命令通常可以嵌套。
举例:IF NOT ERRORLEVEL 1 ECHO 成功!(当ERRORLEVEL为0的时候显示指定信息)
IF %USERNAME%==Hello DIR (当%USERNAME%为Hello时运行DIR命令)
IF EXIST C:\1\2 TYPE C:\1\2 (当存在C:\1\2文件时显示该文件内容)
IF ERRORLEVEL 1 IF NOT ERRORLEVEL 2 PAUSE (当ERRORLEVEL正好为1的时候暂停)
MORE
功能:显示文件内容,每显示一个帖子后提示按任意键继续以显示下一个帖子。
用法:MORE 文件名
说明:MORE命令和TYPE命令十分相似,但MORE命令每显示一个帖子中的内容后将提示按Enter键继续以显示下一个帖子中的内容,或者按ESC或Q键退出。路径既可以是相对路径也可以是绝对路径。如果指定了帖子号的话,MORE将只显示主题中的相应帖子,否则将显示主题中的所有帖子。帖子号为0表示主题帖,1表示第一个回帖,以此类推。负数则表示从最后一个帖子开始数起。开关/A、/D、/P、/S分别用于不显示附件、禁用 Discuz! 代码、不显示投票结果、不显示个人签名,用法和TYPE命令一致。
举例:MORE A:\AUTOEXEC.BAT (显示A:\AUTOEXEC.BAT文件内容)
MORE C:\1\2 (显示C:\1\2这个主题中的所有帖子,每显示一个帖子中的内容后将提示按键继续以显示下一个帖子中的内容)
MORE C:\1\2 3,4 /S (从C:\1\2这个主题的第3个回帖开始显示4帖子,并且不显示个人签名)
NET
功能:管理当前用户。
用法:NET
或 NET FILE
或 NET LOGON 用户名 密码
或 NET SEND 用户1,
或 NET SEND FOR|RE 文件名
或 NET USER
或 NET VIEW
说明:NET命令用于操作当前用户,包括用户登录/登出、显示用户状态和资料、订阅主题、发送短消息等等。它支持许多命令名以实现不同的操作(如果不加参数且已经登录则将显示当前用户名),例如:
NET FILE:显示、加入或取消订阅的文件/主题(订阅的文件可以快速进行访问,比如可直接用TYPE ~2来显示C:\1\2这个已订阅的文件中的内容;TYPE ~+1可以直接显示最新更新的订阅文件的内容,等等);
NET GROUP:显示论坛中所有的用户组,以及它们的积分要求等;
NET LOGON:用指定的用户名和密码登录,十分快捷方便;
NET LOGOFF:登出当前用户;
NET SEND:给用户发送短消息,用户名可以直接在命令行上指定(如果有多个用户可用逗号分隔,如NET SEND TO 用户1,用户2,其中TO可以省略;对于版主或管理员还可以指定*号以发送给所有用户),或者将发送短消息给指定文件(帖子/短消息)的作者,如NET SEND FOR C:\1\2或NET SEND RE C:\1\2,其中后者可以用于引用回复对方的短消息;
NET STATISTICS(可简写为NET STATS):显示论坛统计数据,例如发帖情况等;
NET TIME:显示当前服务器时间和用户上次登录时间;
NET USER:显示指定用户的级别、积分、时间等信息,默认为当前用户;
NET VIEW:显示用户在线列表,可以指定用户名以显示指定用户的在线情况。
举例:NET (显示当前用户名,如果已经登录)
NET LOGON user password (使用user这个用户名和password这个密码来登录)
NET LOGOFF (登出当前用户)
NET FILE(显示用户订阅的文件)
NET FILE C:\1\2(订阅文件C:\1\2)
NET GROUP(显示论坛中所有的用户组)
NET TIME (显示当前服务器时间和用户上次登录时间)
NET SEND a,b(给用户a和b发送短消息)
NET SEND RE C:\1\2(给C:\1\2文件的作者发送/回复短消息)
NET STATS (显示论坛统计数据)
NET USER abc(显示用户abc的信息)
NET VIEW(显示用户在线列表)
PAUSE
功能:暂停命令。
用法:PAUSE
说明:和DOS/CMD下类似,PAUSE命令将暂停命令的执行并显示一行文字。当在批处理中执行且BREAK为ON的时候,用户此时可以按Ctrl+C或Ctrl+Break键来中断批处理文件。
举例:PAUSE (暂停)
POPD
功能:还原之前由PUSHD命令保存的目录。
用法:POPD
说明:和CMD下类似,POPD命令将还原由PUSHD命令上次保存的目录。
举例:POPD (还原上次由PUSHD命令保存的目录)
PROMPT
功能:修改命令提示符。
用法:PROMPT
说明:和DOS/CMD下类似,PROMPT将修改DOS命令提示符界面的提示符。它支持以下特殊字符:
$A &字符
$B |字符(管道符号)
$C (字符(正括号)
$D 当前日期
$F )字符(反括号)
$G >字符(大于号)
$H 退格(清除前一个字符)
$L <字符(小于号)
$N 当前驱动器
$P 当前驱动器和路径
$Q =字符(等号)
$S 空格
$T 当前时间
$V 系统版本号
$$ $字符
默认值为$P$G。当不加参数时,PROMPT将恢复为默认值。除直接使用PROMPT命令来修改提示符外,也可以通过%PROMPT%环境变量来修改,这些均与DOS/CMD下一致。
举例:PROMPT %USERNAME%: $P$G (在命令提示符前面包含用户名)
PUSHD
功能:保存当前目录然后改变目录。
用法:PUSHD
说明:和CMD下类似,此命令将保存当前目录,然后进入指定的目录(类似CD命令)。其后可以用POPD命令还原到所保存的目录。不带参数的PUSHD命令将显示上次保存的目录(如果有的话)。
举例:PUSHD C:\1 (保存当前目录并将目录改为C:\1)
REM
功能:加上注释。
用法:REM
说明:和DOS/CMD下类似,此命令中的内容将被忽略,但可以增加批处理文件的易读性。
举例:REM 开始运行.. (简单的注释)
REN(或RENAME)
功能:重命名文件。
用法:REN 文件名1 文件名2
说明:和DOS/CMD下类似,REN命令可用于重命名文件。其中文件名1为原名,文件名2为新名。文件名2的路径将和文件名1的路径相同。
举例:REN A:\FILE1.TXT FILE2.TXT (将文件FILE1.TXT更名为FILE2.TXT)
SET
功能:显示、设置和删除环境变量。
用法:SET ]
说明:和DOS/CMD下类似,当不加参数的时候,SET命令将显示当前所有的环境变量,否则将把指定变量名的值设置为指定的字符串,或者如果未指定字符串时将删除该变量名。另外,如果参数中只包含变量名而不包含等号和字符串时,SET命令将显示所有以该变量名开头的环境变量;当未手工设置%CD%、%DATE%、%TIME%、%RANDOM%、%ERRORLEVEL%环境变量时,它们将分别自动展开为当前路径、当前日期、当前时间、一个随机整数、当前ERRORLEVEL值,这些均与CMD下一致。
举例:SET (显示所有变量)
SET A=B (将%A%的值设为B)
SET A= (删除环境变量%A%)
SET C (显示所有以C开头的环境变量)
SHIFT
功能:更改批处理文件中可替换参数的位置。
用法:SHIFT
说明:和DOS/CMD下类似,SHIFT命令该对批处理文件中的每个可替换参数向前移一位,例如%1将变成%0、%2将变成%1等,以存取多于10个命令行参数。可以多次使用此命令以移动多个位置。
举例:SHIFT (将可替换参数向前移一位)
TIME
功能:显示当前时间。
用法:TIME
说明:此命令将显示当前时间。另外,当未手工设置%TIME%环境变量时,%TIME%将自动展开为当前时间,和CMD下一致。
举例:TIME (显示当前时间)
TITLE
功能:设置命令提示符的窗口标题。
用法:TITLE
说明:和CMD下类似,此命令可以设置DOS命令提示符界面的窗口名称。如果不加参数的话将恢复默认值。
举例:TITLE 我的命令提示符 (设置窗口标题为“我的命令提示符”)
TYPE:
功能:显示文件内容(即查看主题中的帖子内容)。
用法:TYPE 文件名 ]
说明:和DOS/CMD下类似,TYPE命令将一次性显示指定文件(主题)中的内容。路径既可以是相对路径也可以是绝对路径。如果指定了帖子号的话,TYPE将只显示主题中的相应帖子,否则将显示主题中的所有帖子。帖子号为0表示主题帖,1表示第一个回帖,以此类推。负数则表示从最后一个帖子开始数起。数量可以用于指定从指定帖子号开始显示的帖子数量,如果为负数则表示显示至文件的倒数第"数量"个帖子(-1即文件的末帖),如果不指定数量则默认为1,作用和EDIT、FIND等命令一致。例如TYPE C:\1\2 3,-1表示从C:\1\2这个文件的第3个回帖开始显示到最后一个帖子。开关/A、/D、/P、/S分别用于不显示附件、禁用 Discuz! 代码、不显示投票结果、不显示个人签名。
举例:TYPE A:\AUTOEXEC.BAT (显示A:\AUTOEXEC.BAT文件内容)
TYPE C:\1\2 (显示C:\1\2这个主题中的所有帖子)
TYPE C:\1\2 3 (显示C:\1\2这个主题中的第3个回帖)
TYPE C:\1\2 -1 (显示C:\1\2这个主题中的最后一个帖子)
TYPE C:\1\2 4,2 (从:\1\2这个主题中的第3个回帖开始显示2个帖子)
TYPE C:\1\2 5,-1 /A /S (显示C:\1\2这个主题中从第5个回帖开始的所有帖子,但不显示附件和个人签名)
VER:
功能:显示系统版本。
用法:VER
说明:和DOS/CMD下类似,此命令将显示系统版本。另外此命令有一个隐藏参数/R,可用于显示更多信息,和DOS下一致。
举例:VER (显示版本)
VOL
功能:显示磁盘卷标和序列号。
用法:VOL
说明:和DOS/CMD下类似,此命令将显示指定驱动器的卷标和序列号。如果不加参数的话将显示当前驱动器的卷标和序列号。
举例:VOL D:(显示D盘的卷标和序列号)
此外还有一个隐藏命令TRUENAME(和纯DOS下相同),并支持某些Unix形式的命令,如LS、CAT、PWD、CLEAR等。
第五部分:开发说明
论坛DOS命令提示符界面由中国DOS联盟的Wengier和Roy编写(开始由Roy制作至Alpha 1.25版,其后主要由Wengier进行更新,至目前的4.0版本)。从最初的Alpha测试版,历经很多的中间测试版本,通过不断的测试、改进到现在的正式版本。欢迎大家提出各项建议,使其不断完善,并在此特别感谢qzwqzw、asbai、tigerpower、electronixtar等网友的支持或改进建议。
当DOS命令提示符界面出现新版本时,本帖也将相应更新,以及时反映最新内容。
3.0正式版以来的主要版本更新历史:
4.0版:重写多语言接口并加入950(繁体中文)代码页(可自动根据浏览器的默认语言来选择起始代码页)、加入TYPE/MORE命令的/A、/D、/P、/S开关、加入EDIT命令的/D、/I、/R、/S、/T、/U开关以支持更多编辑功能、NET SEND命令可以引用回复短消息、TYPE/MORE命令支持显示附件/帖图/投票结果/个人签名、支持A盘上自由建立/修改/查看/查找/删除文件、可以运行自定义的批处理文件并支持可替换参数功能、加入REN命令重命名文件、加入SHIFT命令更改批处理文件中的可替换参数的位置、支持Ctrl+Del快捷键清屏,以及其它一些小修改。
3.9版:加入DEL、PUSHD、POPD命令、加入TYPE/MORE命令的帖子显示数量控制、加强EDIT命令权限管理,以及其它一些小修改。
3.8版:加入新驱动器--发件箱、加入文件订阅功能及NET FILE命令管理订阅的文件、加入NET GROUP命令显示所有的用户组、加入NET STATISTICS命令显示论坛统计数据、NET USER和NET VIEW命令支持指定用户名、增强NET SEND命令以支持直接回复指定文件/帖子的作者、FIND命令支持搜索收件箱/发件箱内的文件(短消息)中的内容,以及其它一些小修改。
3.7版:加入新驱动器--收件箱以阅读短消息、NET SEND命令以发送短消息、NET VIEW命令查看用户在线列表,以及其它一些小修改。
3.6版:加入DIR命令的/C开关、同时加入/A和/V开关的各种属性/项目、BREAK命令可以控制EDIT命令是否允许按Ctrl+C键退出,并使当命令行失去焦点的情况下按键可自动恢复命令行,以及其它一些小修改。
3.5版:加入FIND命令的/S开关、加入DIR命令的/W开关、可以用/V开关显示回复数/查看数/帖子数、加强对未授权用户访问版块的限制,以及其它一些小修改。
3.4版:加入CHCP命令和中英文代码页/双语界面支持、允许IE和Firefox下将帖子的code部分复制到剪贴版,以及其它一些小修改。
3.3版:加入COLOR、TITLE命令、改进TYPE/MORE命令的空行处理、解决批处理的一些问题,以及其它一些小修改。
3.2版:加入GOTO命令和标签功能,并使得批处理文件中可以执行除EDIT外的所有命令(而不仅仅是不需要提交到服务器的命令),以及其它一些小修改。
3.1版:加入IF、BREAK命令、解决IE下显示全角空格、DIR的/A开关和PROMPT的$T的一些问题,以及其它一些小修改。
3.0版:加入FIND命令、支持负数作为帖子号、增加%OS%环境变量等,以及其它一些小修改。
Recently, some users have inquired about the basic usage methods of the DOS command prompt interface in the forum, such as how to reply to posts and send private messages from the command line. Given that the previous introductory content about the DOS command prompt interface was scattered in different posts on the forum, and the help for the command prompt interface itself was originally in English (multilingual support, including Simplified and Traditional Chinese, has been supported since version 3.4), now I will summarize the detailed Chinese usage methods of each command in the DOS command prompt interface and common operation problems into this post (equivalent to a user guide). The address of the DOS command prompt interface in the forum is as follows, and everyone can use it while continuing to read:
http://www.cn-dos.net/forum/cmdprmt.php
==
Table of Contents==
1. Brief Introduction
2. Function Overview
3. Common Operations
4. Command Explanation
5. Development Instructions
Part 1: Brief Introduction
The forum's DOS command prompt interface is the web command line version of the China DOS Union forum. It supports various common browsers currently, including Internet Explorer 5.5+, Mozilla Firefox 1.5+, Opera 9+, or browsers fully compatible with them. Now, the forum's DOS command prompt can complete most basic functions that the forum's GUI version can, such as user login/logout, viewing user status or information, browsing posts, editing posts, searching posts, subscribing to topics, sending and receiving private messages, etc. In addition, it has many functions unique to the command line, including freely writing batch files. Its usage method is very similar to the pure DOS and Windows CMD command prompt, integrating the main advantages of these two environments and combining some forum characteristics, especially the characteristics of the China DOS Union forum which focuses on DOS discussion. Through the command line interface, users can complete the functions they want through one command or a series of commands, including simple and complex functions, which are usually more efficient and faster than using the GUI interface. This is also the main reason why many people study and learn the command line and batch processing. At the same time, the forum's DOS command prompt supports the multi-language interface function (including Simplified Chinese, Traditional Chinese, and English). The default starting language is the default language of the user's browser, and the interface display language can be manually specified or switched on the command line at any time (see the CHCP command for details), to give everyone a familiar language environment.
Part 2: Function Overview
The forum's DOS command prompt interface supports most common commands in the DOS/CMD environment, as well as some forum-specific commands, which can be used to directly access and operate the forum. Most commands support some parameters or switches. Users can enter the HELP command at any time on the command line to view the command list and description, and use "HELP command name" or "command name /?" to view more help about the command. The commands supported by the forum's DOS command prompt interface are divided into two categories. One category is commands that do not need to be submitted to the server (similar to internal commands in DOS), and the other category is commands that need to be submitted to the server (similar to external commands in DOS). The former will be executed directly after input, and the latter will be automatically submitted to the server for execution, such as displaying posts, editing posts, sending and receiving private messages, etc. If the latter is executed normally, the returned ERRORLEVEL value is 0; otherwise, the returned ERRORLEVEL value is 1. If the received server response is incorrect, the returned ERRORLEVEL value is 2.
Many concepts and commands used in the forum's DOS command prompt interface are very similar to the corresponding content in DOS/CMD. The files in the DOS command prompt interface are equivalent to topics, posts, and private messages in the forum according to the file system, the directory is equivalent to the forum section, and the drive is equivalent to the forum category and inbox/outbox, etc. The commands inside are also very similar to the functions in DOS/CMD. For example, the DIR command can view files and directories (posts, sections, private messages, etc.); the DEL command can delete files; the REN command can rename files; the TYPE and MORE commands can display the content of files (topics, posts, private messages). Among them, the MORE command will prompt to press a key to continue to display the content of the next post after displaying the content of one post in the topic, which can greatly facilitate the reading of posts especially when there are many posts in the topic; the EDIT command can post new topics, reply to posts, and edit post content. For example, EDIT C:\1 command means to post a new topic in the C:\1 section, EDIT C:\1\2 means to reply to the C:\1\2 topic, and C:\1\2 3 means to edit the 3rd reply in the C:\1\2 topic (where 3 is the post number, 0 means the topic post, 1 means the first reply, and so on, and when it is negative, it starts counting from the last post; and the TYPE, MORE, and FIND commands can also optionally support this usage); the NET SEND command can send/reply to private messages, etc. In addition, for the files subscribed by the user (using the NET FILE command), a faster access to the file can be achieved in the form of ~1. For more detailed information, please refer to the command help and the command explanation below.
Similar to DOS and CMD environments loaded with DOSKEY, the forum's DOS command prompt supports the command line history function. Users can press the cursor keys or PageUp/PageDown keys on the command line at any time to edit or re-call previously entered commands, which greatly facilitates command line operations. The HISTORY command can be used to view the command line history.
The default drive letter after the forum's DOS command prompt interface is started is A (other drive letters respectively represent different sections or special functions. For example, drive C represents the forum's site management area, drive D represents the DOS technology area, drive G represents the inbox, etc., which can be seen with the DIR command). And some environment variables will be automatically set, such as %AUTOSUB%, %CODEPAGE%, %DIRCMD%, %OS%, %PROMPT%, %USERNAME%, which respectively represent whether to automatically subscribe to edited files (default is 1), the current code page (default is 936, which is Simplified Chinese, and can be changed to English with the CHCP 437 command), the pre-set switches of the DIR command (default is /P /V, which can be modified by yourself), the operating system used by the user (such as Windows, POSIX, etc.), the prompt (default is $P$G, which can be modified by yourself), and the user name (if already logged in). In addition, when the user does not manually set these environment variables such as %CD%, %DATE%, %TIME%, %RANDOM%, %ERRORLEVEL%, they respectively represent the current path, current date, current time, a random integer, and the current ERRORLEVEL value, which are consistent with CMD.
Many users like a personalized environment, such as automatically using their favorite colors, fonts, etc. when starting. The forum's DOS command prompt supports storing commands (any command except EDIT) in the A:\AUTOEXEC.BAT file, so that these commands will be automatically run every time it is started. AUTOEXEC.BAT is a self-start batch file, similar to DOS, and will be automatically run every time it is started. The AUTOEXEC.BAT file in the forum's DOS command prompt interface is user-level, and different users can have different AUTOEXEC.BAT files, and users can use it as long as they log in. By appropriately modifying it (using the EDIT command), such as modifying the corresponding environment variables, font, line spacing, color, prompt, window title, etc., users can achieve the purpose of a personalized environment. Not only that, because the content in the AUTOEXEC.BAT file will not disappear, it can also be used to complete functions like favorites. The following is an example of a simple AUTOEXEC.BAT file:
@echo off
break on
rem Set environment variables:
set dircmd=/a/p
set prompt=$t-$p$g
...
goto end
:end
echo The following will modify the font, color, and title. You can press Ctrl+C to cancel.
pause
if %os%#==Windows# font FixedSys
if %os%#==POSIX# font Terminal
font 10%%
color 06
title My DOS Prompt
echo Starting to run..
In addition to the AUTOEXEC.BAT file, users can also freely create and edit other files on drive A, which is equivalent to the user's personal file storage space (different users can create different files). For example, you can use the EDIT A:\HELLO.TXT command to create a HELLO.TXT file on drive A (if it already exists, it will modify the original file). At the same time, you can use other commands to operate these files (the same as the commands in DOS/CMD, such as TYPE/MORE to display the file content, DEL to delete the file, REN to rename the file, etc.). For batch files, users can execute them directly as in DOS/CMD, and can use replaceable parameters such as %0, %1, %2.
Part 3: Common Operations
To facilitate everyone's quick start and use, the following lists the usage methods of some common operations:
1: Switch interface language
The CHCP command can be used to switch the current language code page. For example, CHCP 437 switches the language code page to 437 (English), CHCP 936 switches the language code page to 936 (Simplified Chinese), and CHCP 950 switches the language code page to 950 (Traditional Chinese).
2: Customize the interface
A series of commands such as FONT, COLOR, TITLE, PROMPT can be used to define the interface of the command prompt, such as changing the font, line spacing, color, window title, prompt, etc. Please refer to the usage instructions of these commands for details.
3: View help
All commands have relevant usage help. You can add the /? switch after the command name or use the form HELP to view. If you directly enter the HELP command, it will list all commands. The language of the help information displayed is the language of the current code page.
4: Log in/log out of the forum:
Log in to the forum with the specified user name:
NET LOGON username password (or NET LOGIN username password)
Log out of the current user:
NET LOGOFF (or NET LOGOUT)
5: List forum sections:
You can directly enter the DIR command under drive A to view all sections in the forum. If logged in, user files will also be listed.
If you want to list the sections in the specified category, you can add the corresponding drive letter after the DIR command, such as DIR C: etc.
6: List the topic list in the section:
You can add the corresponding drive letter and path after the DIR command, such as C:\1, etc. If you want to list all topics, you can add the /A switch. The switches of the DIR command can be viewed with DIR /?, or can be specified in the %DIRCMD% environment variable.
7: Display topic content:
The TYPE or MORE command can be used to view the content in the specified topic, such as TYPE C:\1\2 (if the current directory is C:\1, you can directly enter TYPE 2). At the same time, you can specify the starting post and the number of posts to display in the topic. Please refer to the parameters of the TYPE or MORE command for details.
8: Post/reply or edit a post
These can all be completed using the EDIT command. For example, EDIT C:\1 will create a new topic in the C:\1 directory (section), EDIT C:\1\2 will reply to the C:\1\2 file (topic), EDIT C:\1\2 3 will edit the 3rd post in the C:\1\2 topic, etc. If you want to quote a reply, you can use the /R switch. For example, EDIT C:\1\2 3 /R will quote the reply to the 3rd post in the C:\1\2 topic. For more information about the switches of EDIT, you can use EDIT /? to view.
In addition, the EDIT command can also create and edit user files on drive A. Please refer to the usage instructions of the EDIT command for details.
9: Search posts
The FIND command can be used to search the subject and content of posts. For example, FIND "hello" C:\1 will search for all posts containing the string "hello" in the C:\1 directory (section). The FIND command supports many switches, such as finding posts sent by a specified user, displaying the matching lines, displaying all lines of the matching post, searching case-insensitively, searching the string only in the subject, etc. For details, you can use FIND /? to view.
In addition, the FIND command can also search the user files on drive A and the content in the user's private messages.
10: Send and receive private messages
The NET SEND command can be used to send private messages. The usage is NET SEND username. The user's inbox and outbox are all independent drives, which can be seen in the drive list of drive A (the inbox is drive G, and the outbox is drive H). You can use commands such as DIR, TYPE/MORE, FIND in these drives to list, view, search private messages, etc. You can also use the form "NET SEND RE filename" to quote and reply to private messages.
11: Subscribe to topics
The NET FILE command can be used to view the currently subscribed topics. If you want to add or delete the subscribed content, you can add the ADD or DEL parameters respectively. Please refer to the usage of the NET command for details.
12: View user information and status
The NET USER and NET VIEW commands can be used to view the personal information and online status of the specified user respectively. If no user name is added, the user's own information and the online status of all users will be displayed respectively.
13: View forum information
The NET GROUP and NET STATISTICS (can be abbreviated as NET STATS) can be used to view the user group information of the forum and the forum statistics data respectively.
14: Operate user files
You can use commands such as DIR, TYPE/MORE, EDIT, FIND, REN, DEL to operate the user files on drive A (equivalent to the user's personal file storage space). At the same time, users can also directly create or execute BAT batch files.
Part 4: Command Explanation
When the HELP command is entered in the DOS command prompt interface, the following commands can be seen:
BREAK, CD/CHDIR, CHCP, CLS, CMD, COLOR, DATE, DEL/ERASE, DIR, ECHO, EDIT, EXIT, FIND, FONT, GOTO, HELP, HISTORY, IF, MORE, NET, PAUSE, POPD, PROMPT, PUSHD, REM, REN/RENAME, SET, SHIFT, TIME, TITLE, TYPE, VER, VOL
You can use "HELP command name" or "command name /?" in the DOS command prompt interface to view its help. Here is a more detailed description of these commands:
BREAK
Function: Set or clear extended Ctrl+C detection.
Usage: BREAK
Explanation: Similar to DOS, when BREAK is ON (default value), the user can press Ctrl+C or Ctrl+Break command to forcibly interrupt the execution of the command itself or the batch when executing any command or batch file that needs to wait. For example, when executing the DIR or PAUSE command and pressing the Ctrl+C key, it will automatically return to the command line even if the DIR command is still sending. On the contrary, when BREAK is OFF, the user cannot use the Ctrl+C or Ctrl+Break command to forcibly interrupt the execution of the command itself or the batch. In addition, BREAK can control whether the EDIT command allows exiting by pressing the Ctrl+C or Ctrl+Break key when editing the file content.
Example: BREAK (display the current BREAK status)
BREAK ON (set extended Ctrl+C/Ctrl+Break detection)
BREAK OFF (clear extended Ctrl+C/Ctrl+Break detection)
CD (or CHDIR)
Function: Display and change the directory.
Usage: CD
Explanation: Similar to DOS/CMD, this command can display or modify the current path. In addition, when the parameter only includes the drive letter, this command will enter the specified drive, which is the same as in SFTP. CHDIR and CD commands have the same function.
Example: CD (display the current path)
CD .. (enter the parent directory)
CD C:\1 (enter the C:\1 directory)
CHCP
Function: Display or set the active code page number.
Usage: CHCP
Explanation: Similar to DOS/CMD, this command can display or modify the current active code page. This command can be used to switch the language used by the command prompt, including Simplified Chinese (936), Traditional Chinese (950), and English (437 or 850), which is consistent with CMD. The default starting code page is automatically selected according to the default language of the browser. For example, when the default language of the browser is Simplified Chinese, the starting code page is 936 (Simplified Chinese), and when the default language is Traditional Chinese, the starting code page is 950 (Traditional Chinese). Otherwise, the starting code page will be 437 (English). However, it can also be set to the corresponding code page by adding?cp=xxx parameter (where xxx is the code page to be specified, such as 437) in the URL.
Example: CHCP (display the current code page)
CHCP 437 (switch the current code page and interface language to English)
CHCP 936 (switch the current code page and interface language to Simplified Chinese)
CHCP 950 (switch the current code page and interface language to Traditional Chinese)
CLS
Function: Clear the screen.
Usage: CLS
Explanation: Similar to DOS/CMD, this command will clear the content on the screen. In addition, the same effect can be achieved by using the Ctrl+Del shortcut key.
Example: CLS (clear the screen)
CMD (or COMMAND)
Function: Start or refresh the command interpreter.
Usage: CMD
Explanation: The CMD command is automatically called when the DOS command prompt interface is started. Adding the /P parameter will automatically execute the commands in the A:\AUTOEXEC.BAT batch file.
Example: CMD /P (will execute the commands in the A:\AUTOEXEC.BAT batch file)
COLOR
Function: Set the color (foreground and background color) of the command prompt.
Usage: COLOR
Explanation: Similar to CMD, the parameter of the COLOR command consists of two hexadecimal digits, which respectively set the foreground and background colors of the DOS command prompt interface. If no parameter is added, the default value will be restored.
Example: COLOR 07 (or COLOR 7, set the color to black background and white text, which is the same as the default value of COLOR)
DATE
Function: Display the current date.
Usage: DATE
Explanation: This command will display the current date. In addition, when the %DATE% environment variable is not manually set, %DATE% will automatically expand to the current date, which is consistent with CMD.
Example: DATE (display the current date)
DEL (or ERASE)
Function: Delete files.
Usage: DEL filename
Explanation: Similar to DOS/CMD, the DIR command is used to delete files. For topic files, the user must have administrative privileges to delete them; for private message files (i.e., the content in the inbox and outbox), the user can use this command to clean up their private messages as long as they are logged in. The post number 0 means the topic post, 1 means the first reply, and so on. A negative number means counting from the last post.
Example: DEL C:\1\2 -1 (delete the last post in the C:\1\2 file)
DEL G:\3 (delete the 3 file/private message on drive G)
DIR
Function: Display directory contents.
Usage: DIR attribute]] attribute]]
Explanation: Similar to DOS/CMD, the DIR command is usually used to display the files and their information in the specified directory. The range can be controlled with offset,amount. For example, 10,20 means starting from the 10th file and displaying 20 files in total. The default is 0,22, that is, the first 22 files. It can be adjusted through the offset,amount parameter or the /A switch. The DIR command supports the following switches:
/A: List all files with the specified attributes. (And the default is to only display the first 22 files)
The attributes of the /A switch can be (if not specified, it means all):
A Attachment C Closed/Locked D Drive/Directory
G Essence H Hot N New
O Ordinary P Vote T Pinned
/B: Only display the file name
/C: Display the creation date/time of the file/directory (the default is to display the last modification date/time)
/P: Display page by page (prompt to press Enter to continue after displaying 25 files each time, or press ESC or Q to exit)
/S: Also display the content in subdirectories
/V: View customization mode. All information about the specified item will be displayed if possible.
The items supported by the /V switch can be (if not specified, it means all):
A Attribute D Date/time I ID
N Name/Title P Poster/Moderator R Record
In addition, a /W switch is reserved for compatibility but will be ignored.
The attributes of the /A and /V switches can be combined freely to display the corresponding content. A colon can be added between the switch and the option, or it can be omitted. For example, /AFG and /A:FG have the same effect. Using the /V switch can display the attributes, view count, reply count, author, poster, the total number of files and posts in the section, the moderator, etc. of the file/topic. Users can use various attributes of the /V switch to customize the display style, such as not displaying some information to save screen space, etc. Among them, the attributes of the file can be <DIR> (directory/section), <Top> (pinned post), <New> (new post or new message), <Essence> (essence post), <Vote> (vote post), <Locked> (closed/locked post), <Hot> (hot post), <Att> (post with attachment).
If a - character is added before the switch (such as /-A, /-V, etc.), it means canceling the switch. In addition to using it on the command line, these switches can also be pre-specified in the %DIRCMD% environment variable. The default value of %DIRCMD% is /P /V, which can be modified with the SET command, or the - character can be added on the command line (such as /-V) to cancel the specified switch. Except for the default value of %DIRCMD%, these are all consistent with DOS/CMD.
Example: DIR A: /B (only display the names of all files on drive A)
DIR C:\1 /AHT /P (display all pinned or hot files/posts in C:\1 page by page)
DIR C:\1 20,30 (display the files in C:\1, starting from the 20th file and displaying 30 files in total)
DIR C: /A/S/-V (display all files on drive C, including the content in subdirectories, but not display detailed information such as the poster)
ECHO
Function: Display text, or turn on and off command echo.
Usage: ECHO or ECHO
Explanation: Similar to DOS/CMD, ECHO can be used to display the specified text, and can also be used to display or set command echo. When ECHO is ON, the system will echo the current prompt and command. When ECHO is OFF, the opposite is true. Usually, adding @ECHO OFF in the batch file can make the system not display the commands executed in the batch file.
Example: ECHO (display the current ECHO status)
ECHO Hello everyone! (display "Hello everyone!")
ECHO. (display an empty line)
ECHO ON (turn on command echo)
ECHO OFF (turn off command echo)
EDIT
Function: Start the file editor to create and edit files, which can be used for posting, replying, modifying posts, etc.
Usage: EDIT path | filename
Explanation: Similar to DOS/CMD, the EDIT command can be used to edit files. The user must be logged in to use this command. The path can be either a relative path or an absolute path. If the file name is not specified, it means creating a new file in the specified path (i.e., posting a new topic). Otherwise, it means editing the file (including replying and modifying posts). If the post number is specified, EDIT will open the corresponding post in the topic for the user to edit (i.e., modifying the post). Otherwise, it means replying in the topic. The post number 0 means the topic post, 1 means the first reply, and so on. A negative number means counting from the last post. The EDIT command can also be used to create or modify the file on drive A, such as the A:\AUTOEXEC.BAT batch file. In addition, if the value of the %AUTOSUB% environment variable is positive, the edited file (topic) will be automatically subscribed.
The EDIT command supports the following switches:
/D: Disable Discuz! code (enabled by default).
/I: Ignore the points and time restrictions of the post.
/R: Quote the reply post in the file (if the post number is not specified, it defaults to replying to the topic post).
/S: Do not use the personal signature (use by default).
/T: Automatically append the edit date and time after the post when editing the post.
/U: Disable URL recognition (enabled by default).
Example: EDIT A:\AUTOEXEC.BAT (edit the A:\AUTOEXEC.BAT file)
EDIT C:\1 (post a new topic in the C:\1 section)
EDIT C:\1\2 (reply to the C:\1\2 topic)
EDIT C:\1\2 1 /T (edit the 1st reply in the C:\1\2 topic and automatically append the edit date and time after the post)
EDIT C:\1\2 2 /R (quote the reply to the 2nd reply in the C:\1\2 topic)
EDIT C:\1\2 -2 /S (edit the second last reply in the C:\1\2 topic and do not use the personal signature)
EXIT
Function: Return to the graphical interface.
Usage: EXIT
Explanation: This command will return to the graphical interface of the forum.
Example: EXIT (return to the graphical interface)
FIND
Function: Find the specified text in the file.
Usage: FIND "string" | filename
Explanation: The path is used to specify the range of the file to be searched. If the file name is not specified, all files in the path will be searched. The range can also be controlled with offset,amount (the same as the DIR command. For example, 10,20 means starting from the 10th file and searching 20 files in total; if not specified, it means all files). If the post number is specified, FIND will only search from the specified post in the file (topic), otherwise it will search from all posts in the topic. The post number 0 means the topic post, 1 means the first reply, and so on. A negative number means counting from the last post. The string is the string to be searched, enclosed in quotes, and there can be spaces in it. By default, all lines in the file that match the string will be displayed, but it can be adjusted through switches (most are consistent with DOS/CMD):
/A: Display all lines in the post with the specified string
/I: Ignore the case of the string
/C: Only display the number of lines in the file that match the string
/N: Only display the file name that matches the string
/S: Only search the string in the title
/U: Display the content of the post sent by the specified user (if the post number is 0, it means only find and display the topic post sent by the specified user; by default, it searches from the topic post and all reply posts)
/V: Only display all lines that do not match the string.
Example: FIND "ECHO" A:\AUTOEXEC.BAT /V (find and display all lines in the A:\AUTOEXEC.BAT file that do not contain the string ECHO)
FIND "hello" C:\1\2 /N (search for the string hello in the C:\1\2 file, and if it contains this string, display this file name)
FIND "USER" C:\1 0 /U /I (search for all topics sent by USER in the C:\1 directory, and do not distinguish the case of the user name)
FIND "HELLO" C:\8 0,20 4 /A/I/N (in the first 20 files in the C:\8 directory, find and display all posts that contain the string HELLO and are the 4th reply, and do not distinguish the case)
FONT
Function: Display all available fonts or change the current font.
Usage: FONT LIST or FONT or FONT
Explanation: FONT LIST can display the list of all available fonts. FONT will change the current font. The font can be either the font name or the corresponding ID (i.e., the ID seen with the FONT LIST command). For example, 1 represents Courier, 2 represents FixedSys (the default font in CMD), etc. FONT is used to set the line spacing, where the value ranges from 0 to 100.
Example: FONT (display the current font)
FONT LIST (display all available fonts)
FONT FixedSys (change the current font to FixedSys, which has the same effect as FONT 2)
FONT 50% (set the line spacing to 50%)
GOTO:
Function: Jump to a specified label in the batch.
Usage: GOTO label
Explanation: Similar to DOS/CMD, the GOTO command will make the batch file jump to the specified label. In addition, using GOTO :EOF will automatically jump to the end of the batch file, which is consistent with CMD.
Example: GOTO next (assuming there is a :next line in the batch file, GOTO next will jump to this line)
HELP
Function: Provide command help information.
Usage: HELP
Explanation: Similar to CMD, the HELP command will display the help of the specified command, or you can also use the simpler form "command name /?". If no parameter is added, the HELP command will display the list of all commands.
Example: HELP (display the command list)
HELP DIR (display the help of the DIR command, which has the same effect as DIR /?)
HISTORY
Function: Display the command line history.
Usage: HISTORY
Explanation: This command will display the commands entered by the user in the DOS command prompt interface. You can use the arrow keys and PageUp, PageDown to call the previously entered commands, which is consistent with DOS and CMD environments loaded with DOSKEY.
Example: HISTORY (display the command line history)
IF
Function: Complete conditional processing.
Usage: IF ERRORLEVEL value command
IF string1==string2 command
IF EXIST filename command
Explanation: Similar to DOS/CMD, the IF command is used for conditional judgment, including judging whether the current ERRORLEVEL value is greater than or equal to the specified value, whether the specified strings are equal, and whether the specified file exists. NOT means negation. In addition, the IF command can usually be nested.
Example: IF NOT ERRORLEVEL 1 ECHO Success! (display the specified information when ERRORLEVEL is 0)
IF %USERNAME%==Hello DIR (run the DIR command when %USERNAME% is Hello)
IF EXIST C:\1\2 TYPE C:\1\2 (display the content of the C:\1\2 file when the C:\1\2 file exists)
IF ERRORLEVEL 1 IF NOT ERRORLEVEL 2 PAUSE (pause when ERRORLEVEL is exactly 1)
MORE
Function: Display the content of the file, and prompt to press any key to continue to display the next post after displaying the content of one post.
Usage: MORE filename
Explanation: The MORE command is very similar to the TYPE command, but the MORE command will prompt to press the Enter key to continue to display the content of the next post after displaying the content of one post in the topic, or press the ESC or Q key to exit. The path can be either a relative path or an absolute path. If the post number is specified, MORE will only display the corresponding post in the topic, otherwise it will display all posts in the topic. The post number 0 means the topic post, 1 means the first reply, and so on. A negative number means counting from the last post. The switches /A, /D, /P, /S are respectively used to not display the attachment, disable Discuz! code, not display the voting result, not display the personal signature, and the usage is consistent with the TYPE command.
Example: MORE A:\AUTOEXEC.BAT (display the content of the A:\AUTOEXEC.BAT file)
MORE C:\1\2 (display all posts in the C:\1\2 topic, and prompt to press a key to continue to display the content of the next post after displaying the content of one post)
MORE C:\1\2 3,4 /S (start displaying 4 posts from the 3rd reply in the C:\1\2 topic, and do not display the personal signature)
NET
Function: Manage the current user.
Usage: NET
or NET FILE
or NET LOGON username password
or NET SEND user1,
or NET SEND FOR|RE filename
or NET USER
or NET VIEW
Explanation: The NET command is used to operate the current user, including user login/logout, displaying user status and information,