Sa fais presque 1h que j'essai de faire fonctionner mon script pour renommer les pc mais sa me donne toujours l'erreur: Permission denied: 'GetObject' line 11 char 1
Voici la ligne de l'erreur
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Voici mon script :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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