2

I am trying to create a variable / random timeout value, say between 20 and 40.

I need the time out value to be created by some form of random number generator and insert it in the timeout value field.

Any help much appreciated please, this might be a simple task for some of you but it is driving me crazy

Hi. Thank you for that but I am unable to get it to work. Here is the script I am running perhaps you can tell me where I am going wrong.

here is the script I am running

start iexplore.exe www.vhstodvd.eu/About-Us.html
timeout 23 
taskkill /F /IM iexplore.exe

I would like the time out value set at 23 to vary between say 20 and 40.

1
  • It would be helpful to show what you have tried so far.
    – Animesh D
    Nov 24, 2011 at 13:50

1 Answer 1

5

set /a timeout=%RANDOM% * 21 / 32768 + 20

%RANDOM% returns an integer between 0 and 32767.

21 is the range of values you want (20 to 40).

32768 is the range of values returned by %RANDOM% (0 to 32767).

20 is the minimum value you want.

6
  • Hi Thank you for that but i am unable to get it to work. here is the script I am running perhaps you can tell me where I am going wrong. Nov 24, 2011 at 15:49
  • start iexplore.exe www.vhstodvd.eu/About-Us.html timeout 23 taskkill /F /IM iexplore.exe I would like the timeout value which is set at 23 at the moment to vary between 20 and 40. Nov 24, 2011 at 15:51
  • Just replace the timeout value by %timeout% (after get its random value): start iexplore.exe www.vhstodvd.eu/About-Us.html timeout %timeout% taskkill /F /IM iexplore.exe
    – Aacini
    Nov 24, 2011 at 16:01
  • @LeeKowalkowski: I think the dividend value must be 32768, otherwise, if the random value is 32767 the final result will be 41.
    – Aacini
    Nov 24, 2011 at 16:03
  • Thank you Thank you it works much apreciated.. what or why is the figure 32767 0r 23768 is this an equation ? Nov 24, 2011 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.