[BUILD] Randomization script refactoring

1) Refactored randomization logic to the top
2) Add logics to support window platforms
@mrsolo Could you please grep the file for `"%` and add the spaces to this interpolation notation?