troubleshooting Question

VBScript to generate a password based on fixed parameters

Avatar of fruitloopy
fruitloopy asked on
Visual Basic ClassicVB Script
13 Comments4 Solutions550 ViewsLast Modified:
I'm sure this is a quick and easy answer:

I need some vbscript to autmatically read the PC name from the registry and generate a password based on the following parameters...

Example PC Name = "P001440089"

Password equals the last 4 digits of the PC name multiplied by 2
Any leading zeroes should be replaced with a capital X
Final password generated would equal "Pass" & the result above

Example result should be "PassX178"

At the moment I use the following to gain the PC Name:

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
StrComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName"
strValueName = "ComputerName"
objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 4 Answers and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros