windows里有一个名字是 abc 的帐号,我想用命令行或者编程的方式来重命名为user
Sub changeusername()
Dim myname As String, objWMIService As Object, objComputer As Object, r As Long
Name = InputBox("Enter the new computer name below and click OK to continue", "Rename")
Set objWMIService = GetObject("Winmgmts:root/cimv2")
For Each objComputer In objWMIService.InstancesOf("Win32_ComputerSystem")
r = objComputer.rename(Name, "mypassword", "abc")
If r <> 0 Then
MsgBox "Rename failed. Error = " & Err.Number
Else
MsgBox "Rename succeeded." & " Reboot for new name to go into effect"
End If
Next
End Sub