Below is a copy of my script that I'm using to set a random password to the
local administrator.
I would like to improve but would like some help doing it.
I would like to put some error handling in so that I can control an error
and take approrate action if it fails, because at the moment if it fails say
user not found the program just stops.
Also I didn't know if there was a way to query the name of the default local
administrator.
Be honest if needs completly rewriting then say so.
TIA
Gary
Option Explicit
Dim Title, NumChar, Count, strRdm, intRdm, wshShell, oWshNet, sUserName,
sComputerName, oUser
NumChar = 127
Randomize Timer
Do Until Count = NumChar
Count = Count + 1
GetRdm
strRdm = strRdm & Chr(intRdm)
Loop
Sub GetRdm
intRdm = Int((122 - 49) * Rnd + 48)
If intRdm > 57 And intRdm < 65 Or intRdm > 90 And intRdm < 97 Then GetRdm
End Sub
wscript.echo strRdm
Set oWshNet = CreateObject("WScript.Network")
sUserName = "localadmin"
sComputerName = oWshNet.ComputerName
Set oUser = GetObject("WinNT://" & sComputerName & "/"& sUserName & ",user")
oUser.SetPassword(strRdm)
oUser.Setinfo