Do not use on any
shared computer
August 29, 2008 10:16pm pdt
 
[x]
Attachment Details

I Want Random Numbers That Aren't Random

Zone: VB Script
Tags: VBScript
I am trying to setup a VBScript as part of an automated deployment system.  The script should generate a random number based on a formula I specify.  The goal of this is that each system will have a random password, but I want to be able to create the random password again from a different app.  I call the randomize function using my system specific seed, but the problem is on the recreating side.  While my script is able to create a password if that is the only password I want it to generate, if I try to generate multiple passwords (I was trying to output 200 passwords to a text file for our records), the passwords get all screwed up.  Thus I can't recreate passwords unless I redo them one at a time.  This would take a long time to do for +200 systems.  Here is my code more or less:

P.S. if I take this exact code and have it do a wscript.echo Rando(7968-1234) first thing, it gives me the correct password.  The part of my setup that generates the actual password for the build only generates the one password.  It gets the system name using a wscript.network.computername call.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
Set net = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Const ForWriting = 2
 
Dim strOutput(200)
Dim strInput(200)
 
'Creates a spot in the array for the next 200 systems
for i = 0 to 199
	strInput(i) = 7960 + i
	strOutput(i) = ""
next
 
for n = 0 to 199
	StrOutput(n) = StrInput(n)
	strOutput(n) = strOutput(n) - 1234
	strOutput(n) = Rando(strOutput(n)) & vbcrlf
 
	'strEveryOne = strEveryOne & Asset & strInput(n) & vbtab & strOutput(n) & vbcrlf
next
 
'Prints the output to a text file
'Set objFile = objFSO.OpenTextFile("c:\temp.log", ForWriting)
'	objFile.WriteLine(strEveryOne)
'	objFile.close
 
 
 
Function Rando(strSeed)
	Randomize(strSeed) 
	intUpperLimit = 123
	intLowerLimit = 33
 
	For i = 1 to 15
	    intASCIIValue = Int(((intUpperLimit - intLowerLimit + 1) * Rnd) + intLowerLimit)   
		   
		strPassword = strPassword & Chr(intASCIIValue)
	Next
	Rando = strPassword
	strPassword = ""
end function
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Programming
Question Asked By: martel73
Solution Provided By: TRobinJames
Participating Experts: 2
Solution Grade: A
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by TRobinJames
Expert Comment by TRobinJames:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by martel73
Author Comment by martel73:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by TRobinJames
Accepted Solution by TRobinJames:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by martel73
Author Comment by martel73:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by Zinthose
Expert Comment by Zinthose:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628