samedi 10 janvier 2015

Batch random function giving same first output

In my batch program, I have this line in the middle of it:


set /a scramble=%random%


The problem here is that everytime I open the batch file, it gives me the same output, for example I open it and it sets %scramble% to 17534, the next time I open it, it is very similar, for example 17546, increasing by a small amount. If I loop it, then only the first random number is similar, all the rest are random. For example The first time I run it, it gives me this list of numbers: 23486,32645,4854 the second time it gives 23498,26374,17322 So only the first is similar. A simple workaround is to put echo %random% and then cls in the beginning of the batch, so it's not a problem for me, but I'm just wondering why this is?





Aucun commentaire:

Enregistrer un commentaire