0

I have some script which every PC in network download and execute, and the task is NOT to run script simultaneously. So, I used simple pseudo-random for timeout like

TIMEOUT /T 2%random:~0,2%

But as I found out it is not random enough since some PCs still execute script simultaneously. So I decided to make random a bit more random and come up with next code, yet untested

SET /A rnd_time=3%random:~0,2%-1%random:~0,2%
TIMEOUT /T %rnd_time% 

But I am not sure if it will be random enough. So, may be there is a way to get, well, not real random, but pseudorandom which would be random enough for my purpose. Thank you.

4
  • What do you need the number for? Would a GUID be better suited for the task? Commented Dec 15, 2021 at 4:09
  • 1
    True randomness will still produce matching times. I don't think a random is the right solution, rather a controlled pseudo random will allow you to avoid conflicts. Also, if you're using a scheduled task there's already a built in function for randomizing start times. Commented Dec 15, 2021 at 4:28
  • I need number for timeout for script execution. For example: 01. All PC start and download script. 02. One by one all PC execute script with random delay time.
    – alive-one
    Commented Dec 15, 2021 at 5:02
  • Duplicate: Why is %random% in Windows time based and how to get a real random number?. But the better solution is to just throw cmd away and use powershell instead
    – phuclv
    Commented Dec 15, 2021 at 8:50

0

You must log in to answer this question.

Browse other questions tagged .