Windows NT/Windows 2000以后的操作系统为用户提供了两种命令行窗口:cmd.exe和command.com,CMD.EXE是Windows 窗口命令行接口,因此它可以通过窗口右上角的X来关闭,它不是一个dos窗口,而COMMAND.COM是一个16位的DOS应用程序,它用于支持老的dos应用程序,它必须通过命令行输入exit才可以退出,它一般运行于NTVDM中。但就用户来说,这两个命令有惊人的相似之处,如果用户运行command.exe,用户会在任务管理器中看到一个进程ntvdm.exe在运行,如果运行cmd.exe则进程可以看到cmd.exe,而且command.exe还支持以前的16位的现在已经不用的命令。下面分别是2种接口的打开方法和显示结果。
在开始->运行,输入cmd,然后enter。如下:
在开始->运行,输入command,然后enter。如下:
2 窗口的属性
第一种方法:
窗口中输入命令:Cmd [{/A | /U}] [/Q] [/D] [/E: {ON | OFF}] [[/S] [{/C | /K}] string] [/V:{ON |/OFF}] [/T:FG]
参数的含义:
/C string Executes the command specified in the string and then exits the command shell.
/K string Executes the command specified in the string and does not exit the command shell.
/S Modifies the commands used as strings with the /C and /K parameters. Usually, you place quotes around command strings.The /S parameter removes the pening and closing quotes before processing the command.
/A Causes the output of internal commands to be sent to a file (this process is also called piping) in ANSI character format.
/U Causes the output of internal commands to be sent to a file (this process is also called piping) in Unicode character format.
/Q Turns off echo, which is on by default. Echo off mode is also known as quiet mode. When echo is on, each command is displayed as it is processed.
/D Disables the AutoRun command from the Registry.
/E:ON Enables command extensions if they were disabled. Command extensions are enabled by default.
/E:OFF Disables command extensions.
/F:ON Enables the completion of characters for files and directories, which help improve typing speed at the command prompt.
/F:OFF Disables the completion of characters for files and directories.
/V:ON Enables delayed environment variable expansion by using the exclamation point character (!) as the delimiter. This means that using !ThisVar! will expand the variable ThisVar at the time of execution.
/V:OFF Disables delayed environment variable expansion.
/T:FG 设定命令行窗口的前背景色
REM ============================================================================== REM This is an example for setting these vairalbes. Please modify them REM for your own environment. REM ============================================================================== set Source_PathA="E:\A" set Dest_PathB="E:\B"
Path_subst.bat
REM ================================================================= REM run variables_setup.bat to set necessary vairables first REM ================================================================= call variables_setup.bat REM ================================================================= REM substitue dirves REM ================================================================= subst M: /d subst M: "%Source_PathA%" subst N: /d subst N: "%Dest_PathB%"
copy.bat
REM ======== copy files call variables_setup.bat copy /-Y %Source_PathA%\AA\*.txt %Dest_PathB%
2 批处理文件命令
Call 在一个批处理文件中调用另一个批处理文件,原批处理文件继续执行.
Choice 暂停批处理文件的执行,提示让用户选择.
Echo 显示文本和选择显示方式.
Endlocal 还原setlocal中改变的环境变量
For 循环
Goto 跳转.
If 条件选择.
Pause 暂停执行,用户按任意键继续执行.
Rem 注释.
Setlocal 开始使用新的环境变量,知道endlocal.
Shift 被用来改变批处理文件参数的位置.
Standard Handles for Command Redirection
STDIN 0 Standard input is sent from the keyboard.
STDOUT 1 Standard output is sent to the command shell
window.
STDERR 2 Standard error output is sent to the command
shell window.
UNDEFINED 3 through 9 Application-specific handles.
命令组:通过&, &&, and || 实现命令执行的条件选择等,还可以实现带参数的命令组,实例:
Md C:\Reports\Final & Cd C:\Reports\Final 现建立,然后改为工作目录
Cd C:\Reports\Mar98 && Copy Rep5.txt D:\Reports 只有先转到目录mar98,然后才copy文件
Cd C:\Reports\Mar98 || Md C:\Reports\Mar98 如果mar98目录不存在,则创建他(跟编程语言中的差不多的)
RegistryEditorVersion
Blank line
[RegistryPath1]
"DataItemName1"="DataType1:DataValue1"
DataItemName2"="DataType2:DataValue2"
Blank line
[RegistryPath2]
"DataItemName3"="DataType3:DataValue3"