大网数据广告活动
Windows排障命令

rem

· 52CE 我爱测

Reference article for the rem command, which records comments in a script, batch, or config.sys file.

Records comments in a script, batch, or config.sys file. If no comment is specified, rem adds vertical spacing.

Note: This command is internal to the command-line interpreter, cmd.exe.

Syntax

rem [<comment>]

Parameters

Parameter Description
<comment> Specifies a string of characters to include as a comment.
/? Displays help at the command prompt.
Remarks
  • The rem command doesn't display comments on the screen. To display comments on the screen, you must include the echo on command in your file.

  • You can't use a redirection character (< or >) or pipe (|) in a batch file comment.

  • Although you can use rem without a comment to add vertical spacing to a batch file, you can also use blank lines. Blank lines are ignored when a batch program is processed.

Examples

To add vertical spacing through batch file comments, type:

@echo off
rem  This batch program formats and checks new disks.
rem  It is named Checknew.bat.
rem
rem echo Insert new disk in Drive B.
pause
format b: /v chkdsk b:

To include an explanatory comment before the prompt command in a config.sys file, type:

rem Set prompt to indicate current directory
prompt $p$g

To provide a comment about what a script does, type:

rem The commands in this script set up 3 drives.
rem The first drive is a primary partition and is
rem assigned the letter D. The second and third drives
rem are logical partitions, and are assigned letters
rem E and F.
create partition primary size=2048
assign d:
create partition extended
create partition logical size=2048
assign e:
create partition logical
assign f:

For multi-line comments, use conditional execution:

  Rem/||(
    The REM statement evaluates to success,
    so these lines will never be executed.
    Keep in mind that you will need to escape closing parentheses
    within multi-line comment blocks like shown in this example. ^)
  )

Related links

Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Server documentation
适用范围
Windows Server · Source date 10/16/2017
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。