How can I use multiple conditions in "If" in batch file?
batch-file, if-statement
Solution
Adding to dbenham's answer, you can emulate both logical operators (AND, OR) using a combination of `if` and `goto` statements.
To test condition1 AND codition2:
if <condition1> if <condition2> goto ResultTrue
:ResultFalse
REM do something for a false result
goto Done
:ResultTrue
REM do something for a true result
:Done
To test condition1 OR codition2:
if <condition1> goto ResultTrue
if <condition2> goto ResultTrue
:ResultFalse
REM do something for a false result
goto Done
:ResultTrue
REM do something for a true result
:Done
The labels are of course arbitrary, and you can choose their names as long as they are unique.
Problem
Can I specify multiple conditions with "or"/"and" in batch file `if` block? If not that complex, can I at least use something like: ``` if value1 < value < value2 ``` Basically my purpose is to check whether current system time falls in a certain interval(2.05 AM and 7.55 AM to be precise) and if it does, to execute certain commands.