Sunday 23 June 2019

Batch Script: Comments

Comments are used to document the source code. Comments make the program more readable.

Suppose you written thousand lines of program, without proper documentation, after some time, for the owner of the application also, it is very difficult to figure out what was written.

By using comments, you can document your code at the time of writing program. Comments won't affect your program execution. Comments simply document your code.

How to write comments in batch script?
Using REM command, you can record the comments in a batch file.

Syntax
REM [comment]

Any text followed by REM command is treated as command.

Hello.bat
@ECHO OFF

REM Starting the program Execution

REM Printing the version of Windows Operating System
ver

REM Displays the disk volume label and serial number of C Drive
vol C:


C:\Users\Public>Hello

Microsoft Windows [Version 10.0.16299.547]
 Volume in drive C is OSDisk
 Volume Serial Number is 1034-4F6F



Previous                                                 Next                                                 Home

No comments:

Post a Comment