Avatar of sunhux
sunhux
 asked on

Random number generator in Windows 2008 R2 & Win 2012

We plan to put into 1500 VMs' OS scheduler to run daily to make them "activate" back their
agent (could be a backup or Deep Security agent) back to the central server.  Due to unknown
reasons (could be timeout or agent failed to comms back to the server), the software vendor
can't provide a permanent fix or a 'clever' agent that could self-correct itself to re-establish
connection back to the central server (so that central server could manage them)

However, with so many VMs activating back (making Tcp connections) to the central server,
the central server may not be able to take it (ie # Tcp connections max'ed out).

For Linux, I could make the script sleep a random amt of time before activating but for
Windows, is there a random number generator?  I plan to put at the beginning of the
Windows batch script  "ping localhost -n Random_#"  (ie equiv of Linux "sleep Random_amt_time"
Scripting LanguagesMicrosoft Legacy OSWindows Batch

Avatar of undefined
Last Comment
Steve Knight

8/22/2022 - Mon
Steve Knight

On phone at moo but you can use %random% and use set /a to divide it smaller if needed. You can also use ping using -w param to wait that many milliseconds.

Steve
SOLUTION
Steve Knight

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
oBdA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Steve Knight

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
sunhux

ASKER
I could not get the /a right :

set aa=%random%/10
echo %aa%
9433/10


With oBDA's example, it gave missing operand:

set /a RandomMinutes = %Random% %% 60
Missing operand
sunhux

ASKER
This one as well ie it does not evaluated out the actual value but gave a string output:

set num=%random% / 512
22181 / 512
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Steve Knight

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.