1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
' Get Computer Name
Set WshNetwork = CreateObject("WScript.Network")
strComputer = WshNetwork.ComputerName
' WMI method to get local Administrator user name
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAccounts = objWMIService.ExecQuery _
("Select * From Win32_UserAccount Where Domain = '" & strComputer & "'")
For Each objAccount in colAccounts
If Left (objAccount.SID, 6) = "S-1-5-" and Right(objAccount.SID, 4) = "-500" Then
strAdminLocalUserName = objAccount.Name
End If
Next
'Rename the user
strNewName = "Localusr"
set objUser = GetObject("WinNT://" & strComputer & "/" & strAdminLocalUserName & ",user")
set objNewUser = objComp.MoveHere(objUser.ADsPath, strNewName) |
Partager