Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 329 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to "comment-out" (add comment) in a batch/cmd?

#11
Commenting a line
----------------

For commenting line use [REM or ::][1] though `::` might [fail inside brackets][2]

within delayed expansion lines starting with `!<delimiter>` will be ignored so this can be used for comments:

@echo off

setlocal enableDelayedExpansion

echo delayed expansion activated
!;delayed expansion commented line
echo end of the demonstration


Comment at the end of line
--------------------------

For comments at the end of line you can again use `rem` and `::` combined with `&`:

echo --- &:: comment (should not be the last line in the script)
echo --- &rem comment

Commenting at the end of file
-----------------------------

As noting will be parsed after the `exit` command you can use it to put comments at the end of the file:

@echo off

echo commands

exit /b

-------------------
commnts at the end
of the file
------------------

Inline comments
---------------

Expansion of not existing variables is replaced with nothing ,and as setting a variable with `=` rather hard you can [use this for inline comments][3]:

@echo off

echo long command %= this is a comment =% with an inline comment

Multiline comments
------------------

For multiline comments `GOTO` (for outside brackets) and `REM` with conditional execution (for inside brackets) can be used. [More details here][4]:

@echo off

echo starting script

goto :end_comments
comented line
one more commented line
:end_comments

echo continue with the script

(
echo demonstration off
rem/||(
lines with
comments
)
echo multiline comment inside
echo brackets
)


And the same technique beautified with macros:

@echo off

::GOTO comment macro
set "[:=goto :]%%"
::brackets comment macros
set "[=rem/||(" & set "]=)"

::testing
echo not commented 1

%[:%
multi
line
comment outside of brackets
%:]%

echo not commented 2

%[:%
second multi
line
comment outside of brackets
%:]%

::GOTO macro cannot be used inside for
for %%a in (first second) do (
echo first not commented line of the %%a execution
%[%
multi line
comment
%]%
echo second not commented line of the %%a execution
)


[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

[4]:

[To see links please register here]

Reply

#12
I prefer to use:
- REM for comments
- &REM for inline comments

Example:

@echo off
set parameter1=%1%
REM test if the parameter 1 was received
if defined parameter1 echo The parameter 1 is %parameter1% &REM Display the parameter
Reply

#13
Use `::` or `REM`
=
:: commenttttttttttt
REM commenttttttttttt

BUT (as people noted):
=
- if they are not in the beginning of line, then add `&` character:<br/>
`your commands here & :: commenttttttttttt`
- Inside nested parts (`IF/ELSE`, `FOR` loops, etc...) `::` should be followed with normal line, otherwise it gives error (use `REM` there).
- `::` may also fail within `setlocal ENABLEDELAYEDEXPANSION`
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through