Using Errorlevel 0 in a batch file

I am looking at a simple couple of lines that will cause my program to run until it is successfully completed.
I am thinking of using the following within my code:

IF EXIST C:\Progra~1\Player\settingschanged.dat GOTO END

(REST OF CODE DOES IT'S TASKS THEN SENDS TO REBOOT LABEL)

:REBOOT

IF ERRORLEVEL=0 ECHO Settings changed>C:\Progra~1\Player\settingschanged.dat

shutdown -r -f -t 0

:END
EXIT

Thus will run until all done correctly and then file will exist so stop it from running?
deathbybatfileAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

joshlunsfordCommented:
Code for checking  the variable errorcode would be
if %ERRORLEVEL% == 1 echo Settings changed>C:\Progra~ \Player\settingschanged.dat

Open in new window

0
deathbybatfileAuthor Commented:
Thanks Josh.

Would it work as:

IF NOT ERRORLEVEL=1 ECHO.....etc
or would it have to be:
IF NOT %ERRORLEVEL=1 ECHO....etc

This last just for my curiosity really - thanks for the response. :D
0
joshlunsfordCommented:
Would have to be

if not %ERRORLEVEL% == 1 echo blah


variable in batch need percent signs at the beginning and end
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
deathbybatfileAuthor Commented:
That's great - thanks Josh
0
deathbybatfileAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.