' created by Martin Junge 14.5.2012
' the script creates a local Administrator "UserAdmin"
' Password is the individual "Dell Service Tag" + "?"
Dim objWMI : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim colSettingsBios : Set colSettingsBios = objWMI.ExecQuery("Select * from Win32_BIOS")
Dim objComputer, strModel, strSerial
For Each objComputer in colSettings
strModel = objComputer.Model
Next
For Each objComputer in colSettingsBios
strSerial = objComputer.SerialNumber
Next
'wscript.echo strSerial
accUserName = "Useradmin"
accUserPass = strSerial & "?"
QueryForUser(accUserName)
'this section creates the new username if it doesn't exist
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("WinNT://" &strComputer)
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", accUserName)
objUser.SetPassword accUserPass
objUser.Put "UserFlags", 65600 '
objUser.SetInfo
'add user to administrators group
'Set objGroup = GetObject("WinNT://" & strComputer & "/Administratoren,group")
'Set objUser = GetObject("WinNT://" & strComputer & "/" & accUserName & ",user")
'objGroup.Add(objUser.ADsPath)
'msgbox "username was created"
'this section just changes the password if the user exists
Sub QueryForUser(strUserName)
Set objlocal = GetObject("WinNT://.")
objlocal.Filter = Array("user")
For Each User In objlocal
If lcase(User.Name) = lcase(strUserName) Then
strComputer = "."
Set objUser = GetObject("WinNT://" & strComputer & "/" & accUserName & ", user")
objUser.SetPassword accUserPass
objUser.SetInfo
'msgbox User.Name & " already exists." & vbCrLf & "The password was re-set."
WScript.Quit
End If
Next
End Sub
No comments:
Post a Comment