rem

記錄指令碼、批次或 config.sys 檔案中的註解。 如果未指定註解,rem 會新增垂直間距。

注意

此命令是命令列解譯器 (cmd.exe) 的內部命令。

語法

rem [<comment>]

參數

參數 描述
<comment> 指定要包含為註解的字元字串。
/? 在命令提示字元顯示說明。

備註

  • rem 命令不會在螢幕上顯示註解。 若要在畫面上顯示註解,您必須在檔案中包含 echo on 命令。

  • 您無法在批次檔註解中使用重新導向字元 (<>) 或直立線 (|)。

  • 雖然您可以使用 rem 而不加上註解,將垂直間距新增至批次檔,但您也可以使用空白行。 處理批次程式時會忽略空白行。

範例

若要透過批次檔註解新增垂直間距,請輸入:

@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:

若要在 config.sys 檔案中的 prompt 命令之前包含說明註解,請輸入:

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

若要提供有關指令碼用途的註解,請輸入:

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:

針對多行註解,請使用條件式執行:

  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. ^)
  )