Hi all,
I would like to enable the local administrator via VB Scripting. But it doesn't work.
What do I wrong?:
Code:' ChangePassword.vbs ' Sample VBScript to force a user to change password at next logon ' -----------------------------------------------' Option Explicit Dim objOU, objUser, objRootDSE, objShell Dim strContainer, strDNSDomain, strPassword Dim intCounter, intAccValue, intPwdValue ' Bind to Active Directory Domain Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("DefaultNamingContext") ' -----------------------------------------------' ' Important change OU= to reflect your domain ' -----------------------------------------------' strContainer = "OU=Accounts, " strPassword = "P@ssw0rd" strContainer = strContainer ' Here is where we set the value to enable the account ' 512 = Enable, 514 = Disable. intAccValue = 512 ' Here we force a change of password at next logon 'intPwdValue = 0 ' Loop through OU=, setting passwords for all users set objOU =GetObject("LDAP://" & strContainer ) For each objUser in objOU If objUser.class="user" then objUser.SetPassword strPassword objUser.Put "userAccountControl", intAccValue 'objUser.Put "PwdLastSet", intPwdValue objUser.SetInfo End If Next ' Optional section to launch Active Directory Uses and Computers Set objShell=CreateObject("WScript.Shell") objShell.Run "%systemroot%\system32\dsa.msc" WScript.Quit ' End of example: Change Password at next logon VBScript
PS: I havent got a AD. I would only enable the local administrator on my PC and set a password with Test123.
Thanks for help...


Reply With Quote