Hi,
For some XP Home Edition computers being cloned and 'sysprepped' I need
that sysprep runs a script that requests a username and password from
the user and use this information to create a new local user with
administrative rights. In addition the script should rename the
computer object to 'PC-' + username$ where username$ is the username
entered in the script.
The script should have moderate error checking, denying acceptance of a
blank username or password etc. Also it should display a success or
failure message upon completion.
I have managed to glue together something below. However apparently XP
Home has simpler user accounts than XP Pro so the 'set objGroup'
statement below fails on unknown group name. How do I do this properly
in an XP Home environment?
Thanks a lot for comments on this (and on other possible un-elegant
statements below :-)
regards
jake
Option Explicit
' On Error Resume Next
Dim objComputer, objGroup, objUser, objWSHNetwork, strComputerName,
strNewComputerName, strFullName, strPassword, strUserName,
objWMIService, colComputers
Set objWSHNetwork = WScript.CreateObject("WScript.Network")
strComputerName = objWSHNetwork.ComputerName
Set objComputer = GetObject("WinNT://" & strComputerName)
Set objGroup = GetObject("WinNT://" & strComputerName & "/Administrators")
strUserName = InputBox("Please type the given username:", "Enter your
username")
strFullName = InputBox("Please type your real name:", "Enter your real
name")
strPassword = InputBox("Please enter your given password:", "Enter your
password")
strNewComputerName = "PC-" & strComputerName
Set objUser = objComputer.Create("User", strUserName)
objUser.SetPassword strPassword
objUser.FullName = strFullName
objUser.SetInfo
objGroup.Add "WinNT://" & strComputerName & "/" & strUserName
objUser.SetInfo
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery ("Select * from
Win32_ComputerSystem")
For Each objComputer in colComputers
err = objComputer.Rename (strNewComputerName)
Next
MsgBox "Completed renaming computer and adding user " & strUserName &
".", vbInformation, "Execution completed"


