D:\Downloads\CIS_CLEAN_UP\CIS(5)>t abc def
--D:\Downloads\CIS_CLEAN_UP\CIS(5)\t.bat--abc++def--
Divide by zero error.
The system cannot find the path specified.
Missing operand.
Missing operand.
I WANT TO KNOW HOW TO USE ( ... ECHO ON ... )
I know exactly how I caused the deliberate errors.
My actual real life problem involves various scripts which call one another with various parameters.
I enable echo for a region of suspect code so I can see the commands and which gave errors.
@ECHO commands are disabled if this code is executed subject to a condition
Code: Select all
IF "%1%2"=="abcdef" (
@ECHO ON
code that goes wrong
@ECHO OFF
)
A partial solution is to use
IF NOT "%1%2"=="abcdef" GOTO SKIP
and put the :SKIP label at the end of the code.
After years of 'C' I do not like GOTO, and it only works with something like IF ...
Something like this is more tricky to replace brackets :-
Code: Select all
CD /D %P% && (
code that may goes wrong
) || (
other code with possible problems)
)
For simplicity and stand alone testing I am not posting yards of real code,
just a few lines to illustrate the problem I have controlling ECHO within brackets.
This is the code that cannot be debugged :-
Code: Select all
@echo off & setlocal
ECHO --%~dpnx0--
SET /A X11=11
[color=#FF0000]([/color]
SET /A X12=12
SET /A X13=13
@ECHO ON
SET /A X14=14/0
cd /d C:\###\kka\..
SET /A X15=%X16%
SET /A X16=16
SET /A X17-%X16%
SET /A X18=18
@ECHO OFF
SET /A X19=19
[color=#FF0000])[/color]
SET /A X20=20
echo/
If you run the above code you will have the same results.
If you delete the RED open and close brackets you will see all the commands between @echo on and @echo off, and see exactly which commands caused what errors.
OOOOPSS - RED BRACKETS DO NOT LOOK RED IN THE CODE BOX. TRY THIS
SET /A X11=11
(
SET /A X12=12
...
SET /A X19=19
)
SET /A X20=20
Regards
Alan