📄 3.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0049)http://www.hongen.com/pc/newer/os/dos/dos0403.htm -->
<HTML><HEAD><TITLE>洪恩在线 - DOS</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
href="3.files/home.css" rel=stylesheet><LINK href="3.files/tools.css"
rel=stylesheet>
<META content=电脑,乐园,交互,教程,操作系统,DOS,使用,批处理 name=keywords>
<META content="MSHTML 6.00.2800.1561" name=GENERATOR></HEAD>
<BODY text=black bgColor=white leftMargin=0 topMargin=10 marginheight="10"
marginwidth="0"><!--顶部开始-->
<SCRIPT language=Javascript src="3.files/head.js"></SCRIPT>
<!--顶部结束-->
<TABLE height=20 cellSpacing=0 cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD class=p1 align=left bgColor=#e8e8e8 height=19><IMG height=8
src="3.files/blank.gif" width=12><FONT color=#ff9966>当前位置</FONT>:<A
class=under href="http://www.hongen.com/default.htm">洪恩在线</A> -> <A
class=under href="http://www.hongen.com/pc/index.htm">电脑乐园</A> ->
DOS</TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD height=15></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD class=p1 style="COLOR: blue" vAlign=top align=left width=145
bgColor=#e8e8e8><IMG height=10 src="3.files/blank.gif" width=1
align=center><BR>
<TABLE borderColor=#f8ac0e height=20 cellSpacing=0 cellPadding=0 width=128
align=left border=0>
<TBODY>
<TR vAlign=center bgColor=#000099>
<TD class=p2 align=middle width=115><B><FONT
color=#ffffff>DOS</FONT></B></TD>
<TD width=13 bgColor=#e8e8e8 height=20><IMG height=20
src="3.files/title_00.gif" width=13></TD></TR></TBODY></TABLE>
<P style="LINE-HEIGHT: 17pt" align=left> </P>
<P style="LINE-HEIGHT: 17pt"> 一 <SPAN class=p1><A
href="http://www.hongen.com/pc/newer/os/dos/dos0101.htm">DOS概述及入门</A></SPAN><BR> 二
<SPAN class=p1><A
href="http://www.hongen.com/pc/newer/os/dos/dos0201.htm">DOS的常用命令</A></SPAN><BR> 三
<SPAN class=p1><A
href="http://www.hongen.com/pc/newer/os/dos/dos0301.htm">DOS命令集锦</A></SPAN><BR> 四
<SPAN class=p1>使用批处理文件</SPAN><BR> ※ <SPAN class=p1><A
href="http://www.hongen.com/pc/newer/os/dos/dos0401.htm">批处理文件的意义</A></SPAN><BR> ※
<SPAN class=p1><A
href="http://www.hongen.com/pc/newer/os/dos/dos0402.htm">常用命令</A></SPAN><BR> ※
<SPAN class=p1>特殊命令</SPAN><BR> ※ <SPAN class=p1><A
href="http://www.hongen.com/pc/newer/os/dos/dos0404.htm">autoexec.bat</A></SPAN><BR> 五
<SPAN class=p1><A
href="http://www.hongen.com/pc/newer/os/dos/dos0501.htm">如何进行系统配置</A></SPAN><BR> 六
<SPAN class=p1><A
href="http://www.hongen.com/pc/newer/os/dos/dos0601.htm">出错提示与对策</A></SPAN><BR> 七
<SPAN class=p1><A
href="http://www.hongen.com/pc/newer/os/dos/dos0701.htm">其它</A></SPAN>
<P style="LINE-HEIGHT: 17pt" align=center><BR><BR>
<P class=p1 align=center><A
href="http://www.hongen.com/pc/bin/msg.pl?file_id=dos_1" target=_blank
traget="_black"><IMG height=54 alt=请您留言 src="3.files/message.gif" width=64
border=0><BR>谈谈您的看法</A> <BR>
<SCRIPT language=javascript>speak_num="za"</SCRIPT>
<SCRIPT language=javascript src=""></SCRIPT>
<SCRIPT language=javascript>var num=0if (!isNaN(speak_num)){ num=speak_num;}else{ num=0}document.writeln ("已有")document.writeln (num)document.writeln ("条发言")</SCRIPT>
</P>
<P style="LINE-HEIGHT: 17pt" align=center><BR> <BR> </P></TD>
<TD width=1 bgColor=#0586d7 height=304><IMG height=1
src="3.files/blank.gif" width=1> </TD>
<TD vAlign=top width=614 background=3.files/line.gif bgColor=#ffffff>
<TABLE width="95%" align=center border=0>
<TBODY>
<TR>
<TD>
<P align=center><BR><B class=p3>使用批处理文件</B></P>
<P> ——特殊命令
<DIV class=p2 style="LINE-HEIGHT: 17pt">
<P><SPAN class=p2> if goto choice
for 是批处理文件中比较高级的命令,如果这几个你用得很熟练,你就是批处理文件的专家啦。 </SPAN>
<P>
<TABLE cellSpacing=12 width="90%" align=center border=0>
<TBODY>
<TR>
<TD vAlign=top width="13%">if</TD>
<TD width="87%">
<P>表示将判断是否符合规定的条件,从而决定执行不同的命令。 有三种格式: <BR>1、<FONT
color=#0000ff>if "参数" == "字符串" 待执行的命令
</FONT><BR>参数如果等于指定的字符串,则条件成立,运行命令,否则运行下一句。(注意是两个等号)<BR>如if
"%1"=="a" format a: </P>
<P>2、<FONT color=#0000ff>if exist 文件名 待执行的命令
</FONT><BR>如果有指定的文件,则条件成立,运行命令,否则运行下一句。如if exist config.sys
edit config.sys </P>
<P>3、<FONT color=#0000ff>if errorlevel 数字 待执行的命令
</FONT><BR>如果返回码等于指定的数字,则条件成立,运行命令,否则运行下一句。如if errorlevel 2
goto x2 DOS程序运行时都会返回一个数字给DOS,称为错误码errorlevel或称返回码</P></TD></TR>
<TR>
<TD vAlign=top width="13%">goto</TD>
<TD width="87%">
<P>批处理文件运行到这里将跳到goto 所指定的标号处, 一般与if配合使用。 如:</P>
<P>goto end </P>
<P>:end <BR>echo this is the end</P>
<P>标号用 :字符串 表示,标号所在行不被执行</P></TD></TR>
<TR>
<TD vAlign=top width="13%">choice</TD>
<TD width="87%">
<P>使用此命令可以让用户输入一个字符,从而运行不同的命令。使用时应该加/c:参数,c:后应写提示可输入的字符,之间无空格。它的返回码为1234……</P>
<P>如: choice /c:dme
defrag,mem,end<BR>将显示<BR>defrag,mem,end[D,M,E]?</P>
<P>例如,test.bat的内容如下: <BR>@echo off <BR>choice /c:dme
defrag,mem,end <BR>if errorlevel 3 goto defrag
应先判断数值最高的错误码<BR>if errorlevel 2 goto mem <BR>if errotlevel 1
goto end </P>
<P>:defrag <BR>c:\dos\defrag <BR>goto end </P>
<P>:mem <BR>mem <BR>goto end </P>
<P>:end <BR>echo good bye</P>
<P>此文件运行后,将显示 <FONT
color=#0000ff>defrag,mem,end[D,M,E]?</FONT> 用户可选择d m e
,然后if语句将作出判断,d表示执行标号为defrag的程序段,m表示执行标号为mem的程序段,e表示执行标号为end的程序段,每个程序段最后都以goto
end将程序跳到end标号处,然后程序将显示good bye,文件结束。</P></TD></TR>
<TR>
<TD vAlign=top width="13%">for</TD>
<TD width="87%">
<P>循环命令,只要条件符合,它将多次执行同一命令。 </P>
<P>格式FOR [%%f] in (集合) DO [命令] <BR>只要参数f在指定的集合内,则条件成立,执行命令
</P>
<P>如果一条批处理文件中有一行: <BR>for %%c in (*.bat *.txt) do type %%c
<BR>含义是如果是以bat或txt结尾的文件,则显示文件的内容。</P></TD></TR></TBODY></TABLE>
<P> </P></DIV></TD></TR></TBODY></TABLE>
<P align=center> </P>
<P class=p1 align=center><A
href="http://www.hongen.com/pc/newer/os/dos/dos0402.htm">上一节</A> <A
href="http://www.hongen.com/pc/newer/os/dos/dos0404.htm">下一节</A></P>
<P class=p2 align=center><A
href="http://www.hongen.com/pc/bin/msg.pl?file_id=dos_1"
target=_blank><IMG height=54 alt=请您留言 src="3.files/message.gif" width=64
border=0><BR>谈谈您的看法</A>
<SCRIPT language=javascript>speak_num="za"</SCRIPT>
<SCRIPT language=javascript src=""></SCRIPT>
<SCRIPT language=javascript>var num=0if (!isNaN(speak_num)){ num=speak_num;}else{ num=0}document.writeln ("已有")document.writeln (num)document.writeln ("条发言")</SCRIPT>
</P>
<P> </P></TD></TR></TBODY></TABLE><!--底部开始-->
<SCRIPT language=Javascript src="3.files/foot.js"></SCRIPT>
<!--底部结束--></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -