REM

By: Chief Editor/Director on 2022-02-14 at 10:26:38 | Views: 2

In a batch file REM signifies a comment or REMARKadding :: at the start of a line has a similar effectFor example:@ECHO OFF:::: First comment::REM Second commentREM::Although you can use rem without a comment to add vertical spacing to a batch file, you can also use blank lines. The blank lines are ignored when processing the batch program.The double-colon is not documented as a comment command, it is a special case of a CALL label that acts like a comment. The pro&qt;&qt;s and cons of each method are listed below.BugsThere are problems using a :: comment within an IF or FOR code brackete.g.@echo offFOR /L &qt;&qt;i IN (1,1,10) Do (Echo before comment:: Some commentEcho after comment)The above will return the error :: was unexpected at this time.In the script below the DIR command will set an &qt;errorlevel&qt;=2 if the file is not found, but the REM command is then executed successfully and resets &qt;errorlevel&qt;=0 If you use :: for the comment the errorlevel stays at 2. DIR nonexistentfile.txtREM some commentECHO &qt;errorlevel&qt;The problem above was fixed* in Win XP and later service packs of NT 4.Finally in Windows 2000 and XP a comment like::&qt;~ or REM &qt;~ will be interpreted giving the error:The following usage of the path operator in batch-parameter substitution is invalid: &qt;~The bottom line on this is that you must test your comments to be sure they will be ignored as you expect.Registry CommentsWithin a registry file comments can be preceded by "; " e.g.;; Turn the NUMLOCK on at login; [HKEY_CURRENT_USERControl PanelKeyboard] "InitialKeyboardIndicators"="2"FTP CommentsThere is no valid comment character for FTP but you can cheat by escaping to the shell and running REMe.g.C:WORK>type ftpscript!REM This is a remarkbyeC:WORK>ftp -s:ftpscriptftp> !REM This is a remarkftp> byeC:WORK>* The errorlevels set by DIR are different under Windows NT 4 and XP



Previous Next