📎 AI Summary:
The original poster is seeking help with a batch script that calculates the difference between two times. They report that the first conditional statement works correctly, but the second does not execute as expected, and they are asking for assistance. The overall sentiment reveals frustration or confusion, with the user reaching out to the community for guidance.

ukr

Senior Member
Member details
Joined
May 27, 2020
Messages
12
Thread Author #1
Ich habe folgendes Batch-Skript geschrieben:
Code:
Setlocal enabledelayedexpansion
Set /A h1 = 12
Set /A m1 = 10
Set /A h2 = 14
Set /A m2 = 50
If %h2% GTR %h1% (
    Set /A h = %h2% - %h1% -1
    Set /A m = 60 - %m1% + %m2%
    If "%m%" GEQ 60 (
        Set /A m = %m% - 60
        Set /A h = %h% + 1
        )
    ) Else (
        Set /A h = 0
        Set /A m = %m2% - %m1%
    )
    Echo %h% Stunde(n) und %m% Minuten
    pause
Die erste If-Bedingung wird einwandfrei ausgewertet und die Anweisungen werden ausgeführt. Die zweite If-Bedingung wird jedoch nicht ausgeführt und ich bekomme nicht heraus, woran dies liegen könnte. Kann mir jemand helfen bzw. zeigen, ob und wo sich evtl. ein Fehler eingeschlichen hat?

An image from 'Probleme mit Batch-Skript - If-Verschachtelung'. A batch script calculating and displaying time difference in hours and minutes on Windows CMD.
 

Last edited by a moderator:

ukr

Senior Member
Member details
Joined
May 27, 2020
Messages
12
Thread Author #2
Hat den niemand in der Community eine Idee hierzu?