Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

objUser.SetInfo Error 80070005

$
0
0

Hello I Want to use this script as a startup script to my domain to change the local admins passwords. The password is passed as a parameter. The problem is when i run it on windows 8.1 or windows 7 the line objUser.SetInfo throws an Access Denied Error number 80070005.

I'm using a domain admin account to run this script, i verified that i have admin permissions in the local machine. And already run it in a pronpt as an administrator.
                         

If WScript.Arguments.Count <> 1Then
 WScript.Quit 
EndIf

Set objNetwork = CreateObject("Wscript.Network") 
strComputer = objNetwork.ComputerName 

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 

Set colAccounts = objWMIService.ExecQuery _ 
    ("Select * From Win32_UserAccount Where Domain = '" & strComputer & "'") 

ForEach objAccount in colAccounts 
IfLeft (objAccount.SID, 6) = "S-1-5-"andRight(objAccount.SID, 4) = "-500"Then
      WScript.Echo 
strComputer
      WScript.Echo objAccount.Name
Set objUser = GetObject("WinNT://" & strComputer & "/" & objAccount.Name & "") 
      objUser.SetPassword WScript.Arguments(0) 
      objUser.SetInfo 
EndIf
Next

WScript.Quit


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>