1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| ' Input Section
strComputer =InputBox("Old Name?")
sNew =InputBox("New Name?")
sDomainUser ="MyDomain\" & InputBox("Domain Admin Username")
sDomainPasswd =InputBox("Password (NOT hidden!)")
sAdminUser =strComputer & "\administrator"
sAdminPassword ="MyAdminpassword"
' Start Remote Registry
strService = " 'RemoteRegistry' "
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strcomputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name =" & strService & " ")
For Each objService in colListOfServices
WSCript.Sleep 1500
objService.StartService()
Next
WScript.Echo "Started " & strService & " on " & strComputer
' Rename strComputer
set oWMILocator = CreateObject("WbemScripting.SWbemLocator")
oWMILocator.Security_.AuthenticationLevel = 6
set oWMIComputer = oWMILocator.ConnectServer(strComputer, "root\cimv2",strComputer & sAdminUser,sAdminPassword)
set oWMIComputerSystem = oWMIComputer.Get("Win32_ComputerSystem.Name='" & strComputer & "'")
rc = oWMIComputerSystem.Rename(sNew,sDomainPasswd,sDomainUser) |
Partager