0

I am trying to make a small batch program which will re-start a program when it detects that it is not running, and also restart the program once a while.

Here is the part which CMD just says "The syntax of the command is incorrect" (won't parse after the first if statement). Both variables are set with the /a statement, so they should both be proper integers.

IF %delayer% GTR %resetDelay% (

IF NOT %resetDelay% EQU 0 (
  CALL :RESETMINER
  ECHO [%TIME%] %minerProcess% - scheduled restart completed.
  SET /a delayer=0
) ELSE (
  TIMEOUT %checkDelay%
)

) ELSE (

SET /a delayer=%delayer%+%checkDelay%
TIMEOUT %checkDelay% /nobreak
::Delete /nobreak if you want to skip the 'Wait' sequences by pressing any key

)

Here is the whole code //Removed, not important

3
  • I haven't read your 'whole code' but I would suggest using the following in your snippet instead: IF %resetDelay% NEQ 0 ( or IF NOT %resetDelay% == 0 ( and SET /a delayer+=checkDelay or SET /a delayer=delayer+checkDelay. Commented Jan 5, 2018 at 1:44
  • In the if /? shows that NOT is not part of that compare-op syntax. Commented Jan 5, 2018 at 1:51
  • 1
    @ACatInLove, I can't follow you, but in the above code snippet, not is is used perfectly fine... Commented Jan 5, 2018 at 8:55

1 Answer 1

1

Don't use ::-comments within a code-block (parenthesised sequence of lines) as it causes problems. Change it to rem comment.

Sign up to request clarification or add additional context in comments.

1 Comment

Oh thanks a lot, that solved my problem... I didn't even thought that this could be a problem!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.