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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change password on a machine in a workgroup with different credentials

Status
Not open for further replies.

koolestj

Technical User
May 8, 2002
14
US
I am trying to create this vbscript so I can change the passwords on our hosted 2kserver machines in a workgroup. I will be running the script from my computer in a domain and I will need to pass different username/password combo with admin rights to the servers to run the script. I wonder if at all possible. Here's my script btw: (Note: this is the test script and once I validate that it works I will add necessary code to create the loop).
I picked up bits and pieces there and I don't understand why there is a need for sAltUser, sAltPass. Please help!

Const ADS_SECURE_AUTHENTICATION = 1
Const ADS_USE_ENCRYPTION = 2

sComp = "fid-etl"
sUser = "kjagpal"
sAltUser = "adminuser"
sAltPass = "adminpass"


Set oDSO = GetObject("WinNT:")
Set oUser = oDSO.OpenDSObject("WinNT://" & sComp & "/" & sUser, sAltUser, sAltPass, ADS_SECURE_AUTHENTICATION AND ADS_USE_ENCRYPTION)
oUser.SetPassword "12345"
Msgbox 'Done'


 
Thx PHV but I still have trouble trying to use setPassword with the SWbemLocator object.
I get a Permission denied: 'getObject'
 
btw, the my script looks like this now.

strComputer = "somebox"
strNamespace = "root\cimv2"
strUser = "somename"
strPassword = "somepassword"

Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objwbemLocator.ConnectServer _
(strComputer, strNamespace, strUser, strPassword)
objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy

Set objUser = GetObject("WinNT://" & strComputer & "/Administrators, user")
objUser.SetPassword "abc123"
objUser.SetInfo
Msgbox 'Done'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top