Solved Having trouble with If statements in Batch file

April 2, 2017 at 15:22:21
Specs: Windows 10
Im at witts end trying to figure out what's wrong with my batch file

I can't seem to get some of the statements to work, and the final echo statement isn't appending tot he document. Can anyone chime in?


@echo off


type NUL > results.txt

echo My Name is ****** > results.txt
echo The Current date is %date% >> results.txt
echo The Current time is %time% >> results.txt
echo My name is ****, the current date is %date% and the current time is %time%


SET /P FirstNumber=Enter the First Number and press Enter :
if %FirstNumber% == "66" goto LOOP


SET /P LastNumber=Enter the Second Number and press Enter:
if %LastNumber% == "0" goto ZeroError
if %LastNumber% == "66" goto LOOP
goto CALC

SET /P zError =You CAN NOT divide by Zero, enter a correct number and press Enter:
if %LastNumber% == "66" goto LOOP
if %LastNumber% == "0" goto ZeroError
goto CALC


set /A calculation = %FirstNumber% / %LastNumber%
echo %FirstNumber% divided by %LastNumber% equals %calculation%
echo %FirstNumber% divided by %LastNumber% equals %calculation% >> results.txt



FOR /L %%A IN (1,1,10) DO(

SET /A MOD= %%A %% 6
SET /A MODPlus= !MOD! + 2


echo The mean of the values is %AVERAGE% >> results.txt

mkdir pgm4
cd pgm4
type NUL > one.txt
echo REM ***** >> one.txt
echo echo ****** >> one.txt
ECHO. >> one.txt


* In my FirstNum label the program just keeps going despite me entering 66 in the prompt

* Similar issue in SecondNum

* the echo after the :LOOP doesn't append the average value to the text file.

Can anyone point me in the direction of what Im doing wrong?

See More: Having trouble with If statements in Batch file

Report •

April 2, 2017 at 18:56:50
✔ Best Answer
if %FirstNumber% == "66" goto LOOP


if %FirstNumber%==66 goto LOOP


if !FirstNumber!==66 goto LOOP


M2 Get custom script or take private lessons

Report •
Related Solutions

Ask Question