Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AD Script: change computer local admin password & disable local guest

Status
Not open for further replies.

AlexIT

Technical User
Jul 27, 2001
802
US
I got started with this in another thread and I am not sure where I went wrong...I am looking to call an AD script from our login.bat file to change the computer's local admin password and to disable the computer's local guest account. I am doing this so each time any machine is used to log into the domain both of these items are performed. (All domain users, except admin accounts, run login.bat...)

Dim fso, ts, password, admin, computer
Set fso = CreateObject("Scripting.FileSystemObject")
Set password = fso_OpenTextFile("\\SERVER1\passowrd.txt", 1)
ts.close

Dim objNet
Set objNet = Createobject("WScript.Network")
admin = "Administrator"
computer = objNet.ComputerName

Dim User
Set User = GetObject ("WinNT://" & computer & "/"& admin &"",user)
Call User.SetPassword(password)

Set objNet = Nothing
Set objUser = GetObject("WinNT://" & computer & "/Guest")
objUser.AccountDisabled = True
objUser.SetInfo
 
All I have is the script below


strComputer = "computername"
Set colAccounts = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = colAccounts.Create("/USERNAME,user")
objUser.SetPassword "1234"
objUser.SetInfo
 
That looks to create a new user in the local administrator's group (unless I am misreading), I need to change the password for the existing (default) administrator's account on the given machine...also I'd need the new password stored outside of the script. If the script is in "\SYSVOL\...\scripts" directory it is accessible to any computer on the network. I was trying to store the password in a non-shared location, and just call this from the script.

Alex
 
This disables the Guest account on the local machine:

Code:
ComputerName = "."
Set CPU = GetObject("WinNT://" & ComputerName & ",Computer")
Set User = CPU.GetObject("User", "Guest") 

User.AccountDisabled = True
User.SetInfo

Try this change to make the above change a password:

Code:
Call User.SetPassword("xyzxyz")

I haven't checked the change password one yet, but it should work.

The above is an adaptation from:
Hope that helps!
 
I haven't any access at the moment, but I thought I'd try this modification of the above:

ComputerName = "."
Set CPU = GetObject("WinNT://" & ComputerName & ",Computer")
Set User = CPU.GetObject("User", "Guest")

User.AccountDisabled = True
User.SetInfo

Set Admin = CPU.GetObject("User". "Administrator")
Call User.SetPassword("xyzxyz")


Do I still need the User.SetInfo after the .SetPassword call??

Thanks,
Alex
 
We initiated this script because of the possibility of admin password hacking via the cracking software readily available on the net.

This works great for me:

strComputer = "."
Set CPU = GetObject("WinNT://" & strComputer & ",Computer")
Set objuser = CPU.GetObject("User", "Administrator")
dim wsh
Set wsh = Wscript.CreateObject("Wscript.Shell")
objUser.SetPassword &quot;<YourNewPasswordHere>&quot;
objUser.SetInfo

CAVEAT WARNING!
If the user running this script (ie: the currentuser on the target machine) is not a member of the local admin group the script will fail!
The workarounds for this are:
Enable local computer policies on the local computers (or use GPO's) and place the vbs in the <Local Computer Policy><Computer Configuration><Windows Settings><Scripts (Startup/Shutdown)><startup.

or

repackage the vbs in an MSI using elevated privileges. I use InstallConstruct or you could use WINstaller. Then any user can run the script silently.

Personally, I prefer to use the local/group policies angle. In Startup, the script runs before the user logs on (under the system account), so even if someone's hacked the admin password, it gets reset to what you've chosen before the amateur hacker can log on with the new password they set.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top