请教各位我想学一下如何建立一个批处理文件以及它的一些语法!
解决方案 »
- 小弟在学C++,求各位大哥大姐有中文版的MSDN发我一份
- 请各位大侠指教,谢谢.(读取.bak;.txt文件里的内容并取出关联的相关信息生成excel表格)
- 看谁反应快
- 我想弄个漂亮的skin,有免费的.dll吗,谁可以帮帮我?(提供者另外赠高分100)
- OpenGL新手求救!
- 请高手帮忙
- 各位高手能不能在线帮助,我快崩溃了。。。help...
- 不才有个关于数据传输的问题请教各位大虾
- 高分寻一个很简单的例子,出200分,使用own-draw listbox and combo
- 有哪位高手有磁盘擦除的源代码?
- 工具栏的某项如何呈灰显示?
- ODBC API中有那些是对大二进制对象进行操作的?(高分求解)
去看看吧 好好学 hh
可能在AfxGetApp()->中你找找看
但在资源的中的字符串资源中的第一行就是你找一下
(C) 版权所有 1985-2000 Microsoft Corp.C:\>help
若需指定命令的详细信息,请键入“HELP 命令名”。
ASSOC Displays or modifies file extension associations
AT Schedules commands and programs to run on a computer.
ATTRIB Displays or changes file attributes.
BREAK Sets or clears extended CTRL+C checking.
CACLS Displays or modifies access control lists (ACLs) of files.
CALL Calls one batch program from another.
CD Displays the name of or changes the current directory.
CHCP Displays or sets the active code page number.
CHDIR Displays the name of or changes the current directory.
CHKDSK Checks a disk and displays a status report.
CHKNTFS Displays or modifies the checking of disk at boot time.
CLS Clears the screen.
CMD Starts a new instance of the Windows 2000 command interpreter.
COLOR Sets the default console foreground and background colors.
COMP Compares the contents of two files or sets of files.
COMPACT Displays or alters the compression of files on NTFS partitions.
CONVERT Converts FAT volumes to NTFS. You cannot convert the
current drive.
COPY Copies one or more files to another location.
DATE Displays or sets the date.
DEL Deletes one or more files.
DIR Displays a list of files and subdirectories in a directory.
DISKCOMP Compares the contents of two floppy disks.
DISKCOPY Copies the contents of one floppy disk to another.
DOSKEY Edits command lines, recalls Windows 2000 commands, and creates macros.ECHO Displays messages, or turns command echoing on or off.
ENDLOCAL Ends localization of environment changes in a batch file.
ERASE Deletes one or more files.
EXIT Quits the CMD.EXE program (command interpreter).
FC Compares two files or sets of files, and displays the differences
between them.
FIND Searches for a text string in a file or files.
FINDSTR Searches for strings in files.
FOR Runs a specified command for each file in a set of files.
FORMAT Formats a disk for use with Windows 2000.
FTYPE Displays or modifies file types used in file extension associations.
GOTO Directs the Windows 2000 command interpreter to a labeled line in a
batch program.
GRAFTABL Enables Windows 2000 to display an extended character set in graphics
mode.
HELP Provides Help information for Windows 2000 commands.
IF Performs conditional processing in batch programs.
LABEL Creates, changes, or deletes the volume label of a disk.
MD Creates a directory.
MKDIR Creates a directory.
MODE Configures a system device.
MORE Displays output one screen at a time.
MOVE Moves one or more files from one directory to another directory.
PATH Displays or sets a search path for executable files.
PAUSE Suspends processing of a batch file and displays a message.
POPD Restores the previous value of the current directory saved by PUSHD.
PRINT Prints a text file.
PROMPT Changes the Windows 2000 command prompt.
PUSHD Saves the current directory then changes it.
RD Removes a directory.
RECOVER Recovers readable information from a bad or defective disk.
REM Records comments (res) in batch files or CONFIG.SYS.
REN Renames a file or files.
RENAME Renames a file or files.
REPLACE Replaces files.
RMDIR Removes a directory.
SET Displays, sets, or removes Windows 2000 environment variables.
SETLOCAL Begins localization of environment changes in a batch file.
SHIFT Shifts the position of replaceable parameters in batch files.
SORT Sorts input.
START Starts a separate window to run a specified program or command.
SUBST Associates a path with a drive letter.
TIME Displays or sets the system time.
TITLE Sets the window title for a CMD.EXE session.
TREE Graphically displays the directory structure of a drive or path.
TYPE Displays the contents of a text file.
VER Displays the Windows 2000 version.
VERIFY Tells Windows 2000 whether to verify that your files are written
correctly to a disk.
VOL Displays a disk volume label and serial number.
XCOPY Copies files and directory trees.C:\>help/?
提供 Windows 2000 命令的帮助信息。HELP [command] command - 显示该命令的帮助信息。
C:\>help if
在批程序中执行条件处理。IF [NOT] ERRORLEVEL number command
IF [NOT] string1==string2 command
IF [NOT] EXIST filename command NOT 指定只有条件为 false 的情况下, Windows 2000 才
应该执行该命令。 ERRORLEVEL number 如果最后运行的程序返回一个等于或大于
指定数字的退出编码,指定条件为 true。 string1==string2 如果指定的文本字符串匹配,指定一个 true
条件。 EXIST filename 如果指定的文件名存在,指定一个 true 条件。 command 如果条件符合,指定要执行的命令。如果指定的
条件为 FALSE,ELSE 命令可随在命令之后,ELSE
命令将在 ELSE 关键字之后执行该命令。ELSE 子句必须在 IF 之后出现在同一行上。例如: IF EXIST filename. (
del filename.
) ELSE (
echo filename. missing.
)因为 del 命令需要用一个新行终止,以下子句不会有效:IF EXIST filename. del filename. ELSE echo filename. missing由于ELSE 命令必须与 IF 命令的尾端在同一行上,以下子句也
不会有效: IF EXIST filename. del filename.
ELSE echo filename. missing如果都放在同一行上,以下子句有效: IF EXIST filename. (del filename.) ELSE echo filename. missing如果命令扩展名被启用,IF 会如下改变: IF [/I] string1 compare-op string2 command
IF CMDEXTVERSION number command
IF DEFINED variable command其中,比较运算符可以是: EQU - 等于
NEQ - 不等于
LSS - 小于
LEQ - 小于或等于
GTR - 大于
GEQ - 大于或等于及 /I 命令选项;如果该命令选项被指定,则说明要进行的字符串比较不分
大小写。/I 命令选项可以用于 IF 的 string1==string2 的形式上。这些
比较都是通用的;原因是,如果 string1 和 string2 都是由数字
组成的,字符串会被转换成数字,进行数字比较。CMDEXTVERSION 条件的作用跟 ERRORLEVEL 的一样,除了它
是在跟与命令扩展名有关联的内部版本号比较。第一个版本
是 1。每次对命令扩展名有相当大的增强时,版本号会增加一个。
命令扩展名被停用时,CMDEXTVERSION 条件不是真的。如果已定义环境变量,DEFINED 条件的作用跟 EXISTS 的一样,
除了它取得一个环境变量,返回的结果是 true。如果没有名为 ERRORLEVEL 的环境变量,%ERRORLEVEL%
会扩充为 ERROLEVEL 当前数值的字串符表达式;否则,您会得到
其数值。运行程序后,以下语句说明 ERRORLEVEL 的用法: goto answer%ERRORLEVEL%
:answer0
echo Program had return code 0
:answer1
echo Program had return code 1您也可以使用以上的数字比较: IF %ERRORLEVEL% LEQ 1 goto okay如果没有名为 CMDCMDLINE 的环境变量,%CMDCMDLINE%
将在 CMD.EXE 进行任何处理前扩充为传递给 CMD.EXE 的原始
命令行;否则,您会得到其数值。如果没有名为 CMDEXTVERSION 的环境变量,
%CMDEXTVERSION% 会扩充为 CMDEXTVERSION 当前数值的
字串符表达式;否则,您会得到其数值。C:\>
就可以了呀