jeudi 21 mai 2020

Issues With Bat/CMD conditional if statement no evaluating correctly

I have Written a nice little batch file that appeared to work so I thought, but in testing I found one little subroutine isn't doing it's job and I can't see why. I copied the snippet of code into it's own bat file and swapped the goto functions for simple true false statements to try and figure this out and I still couldn't.

If 28937064448 GTR 21474836480 ( 
echo true 
) else ( 
echo false 
)

The context of this is the free space of a drive is being called and compared to a manually set number. If the free space is greater then the script should jump to do something one way, if the free space is smaller it should jump elsewhere to do it differently.

In the VM I am developing this on the drive size is always to small so I commented out the 150gig number and set it to something that should evaluate to true, and to my surprise nothing would. The other context that is important here is I am pulling the free space from wmic and it is reported in bytes I think. Which if my suspicion about the number being too large has any merit is it's own problem because these numbers are always going to be large.

Aucun commentaire:

Enregistrer un commentaire