Jump to content

Change Administrator password in VBS


Recommended Posts

I'm searched any script or appz for what I need, but no such luck...

I'm doing an unattended cd (win xp) and I wish that, at final, a simple app change the password for the main (admininstrator) account.

I tryed something in VBS:

Set WshShell = Wscript.CreateObject("Wscript.Shell")

function CambiarPass(machine)

wshshell.run "Net User Administrador" & " " & machine,0

end function

msgbox "Cambiar Contraseña de Windows XP SP 2 uE V4" & vbnewline & vbnewline & "Para su mayor seguridad le recomendamos que actualice la contraseña de Windows XP" & vbnewline & vbnewline & vbnewline & vbnewline & "http://www.windowsue.com", vbokonly + vbquestion

call ChangePass

Sub ChangePass()
machine = inputbox ("Importante no usar caracteres especiales y recuerda si usas minúsculas o mayúsculas." & vbnewline & vbnewline & "Por favor indica la nueva contraseña:" & vbnewline & vbnewline & _
"", "Cambiar contraseña")

if machine = "" then
msgbox "¡Contraseña invalida!"
call ChangePass

else

CambiarPass
end if
End Sub

But it seems it doesn't work...

Can anybody help me?

Regards,

Bj

Link to comment
Share on other sites

  • 2 weeks later...

How about a compiled batch file!

[Edit]

Just to qualify the post a little, this probably only works in English language versions and may not work pre-XP.

Basically I made it for those occasions where the Local Administrator Name may have been changed. It therefore doesn't just use

NET USER Administrator Pa5Sw0rd

It attempts to get the correct Local Administrator Name programatically and then does a little checking on the newly supplied password before setting it.

[/Edit]

RootPass.zip

Edited by Yzöwl
Link to comment
Share on other sites

Here try this, replace 'ComputerName' and 'UserName' with the appropriate names and 'NewPassword' with the new password, if using a variable for the password then remove the double quotes also.

Also don't change the case of the 'WinNT' or it won't work.

Set objUser = GetObject("WinNT://ComputerName/UserName")
objUser.SetPassword("NewPassword")

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...