pausepause

暂停批处理程序的处理,并显示提示, Press any key to continue . . .Suspends the processing of a batch program, displaying the prompt, Press any key to continue . . .

语法Syntax

pause

参数Parameters

参数Parameter 说明Description
/?/? 在命令提示符下显示帮助。Displays help at the command prompt.

备注Remarks

  • 如果按 CTRL + C 停止批处理程序,将显示以下消息: Terminate batch job (Y/N)?If you press CTRL+C to stop a batch program, the following message appears, Terminate batch job (Y/N)?. 如果按 Y (为 "是") 响应此消息,批处理程序将结束并控制返回到操作系统。If you press Y (for yes) in response to this message, the batch program ends and control returns to the operating system.

  • 可以在可能不希望处理的批处理文件的一部分之前插入 pause 命令。You can insert the pause command before a section of the batch file that you might not want to process. 暂停暂停 批处理程序的处理时,可以按 CTRL + C,然后按 Y 停止批处理程序。When pause suspends processing of the batch program, you can press CTRL+C and then press Y to stop the batch program.

示例Examples

若要创建一个批处理程序来提示用户更改其中一个驱动器中的磁盘,请键入:To create a batch program that prompts the user to change disks in one of the drives, type:

@echo off
:Begin
copy a:*.*
echo Put a new disk into Drive A
pause
goto begin

在此示例中,驱动器 A 中的磁盘上的所有文件都复制到当前目录中。In this example, all the files on the disk in Drive A are copied to the current directory. 在该消息提示你将新磁盘放入驱动器 A 后, pause 命令将挂起处理,以便你可以更改磁盘,然后按任意键继续处理。After the message prompts you to put a new disk in Drive A, the pause command suspends processing so that you can change disks and then press any key to resume processing. 此批处理程序在无穷循环中运行- goto begin 命令将命令解释器发送到批处理文件的开始标签。This batch program runs in an endless loop—the goto begin command sends the command interpreter to the Begin label of the batch file.

其他参考Additional References