{"id":8315,"date":"2021-11-28T09:53:39","date_gmt":"2021-11-28T09:53:39","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=8315"},"modified":"2021-11-28T09:55:20","modified_gmt":"2021-11-28T09:55:20","slug":"retry-command-a-set-number-of-times","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/retry-command-a-set-number-of-times\/21102.html","title":{"rendered":"Retry Command a Set Number Of Times"},"content":{"rendered":"<p>I am looking to try and improve a batch file I wrote a while back. In the batch file I run a command if the command runs fine I exit out of the batch file if not I wait and retry the command again.<\/p>\n<p>The way I retry the command is a little bit dirty I just run the command again from another label and then another label eg retry:, retry2: ,rety3: ect. I wanted to try and see if I could pass a command to the batch file eg Retry3 this would then try and run the program 3 times and would save me having to have so many retry labels. It would get very messy if I tried to run the program 99 times until it worked correctly<\/p>\n<p>@ECHO OFF<br \/>\nset ERRORLEVEL=<br \/>\nTC %1 %2 %3 %4 %5 %6 %7 %8 %9<br \/>\necho %ERRORLEVEL%<br \/>\nIF ERRORLEVEL 1 GOTO RETRY<br \/>\nIF ERRORLEVEL 0 GOTO END<\/p>\n<p>:RETRY<br \/>\nECHO.<br \/>\nECHO %1 OF %2 FAILED LOOKING TO TRY AND %1 %2 AGAIN.<br \/>\nWAIT 20<br \/>\nset ERRORLEVEL=<br \/>\nTC %1 %2 %3 %4 %5 %6 %7 %8 %9<br \/>\necho %ERRORLEVEL%<br \/>\nIF ERRORLEVEL 1 GOTO RETRY2<br \/>\nIF ERRORLEVEL 0 GOTO END<\/p>\n<p>:RETRY2<br \/>\nECHO.<br \/>\nECHO %1 OF %2 FAILED ANOTHER TIME LOOKING TO TRY AND %1 %2 A SECOND TIME.<br \/>\nWAIT 20<br \/>\nset ERRORLEVEL=<br \/>\nTC %1 %2 %3 %4 %5 %6 %7 %8 %9<br \/>\necho %ERRORLEVEL%<br \/>\nIF ERRORLEVEL 1 GOTO RETRY3<br \/>\nIF ERRORLEVEL 0 GOTO END<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":0},"question-category":[55],"question_tags":[],"class_list":["post-8315","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/8315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=8315"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=8315"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=8315"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=8315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}