Bat file. delete before success?

I run a bat file to clean up, and sometimes it takes a few seconds to complete my application. In it, I delete the database. Instead of waiting or running it several times, I would like the bat file to continue its attempts until it succeeds. How can i do this?

+3
source share
2 answers
goto :foo2
:foo
sleep 1
:foo2
del file
if exist file goto :foo
+6
source

In this code, you rely on your team to set a non-zero error level if (when) it fails. And you know what error code it sets.

Something along the lines

@echo off

:Delete
deletedatabasecommand

if ERRORLEVEL 123 GOTO Delete

That should do it.

0
source

Source: https://habr.com/ru/post/1746641/


All Articles