Script VBS – Reseta senha do administrador local

sNewPassword = “nome senha”

Set oWshNet = CreateObject(“WScript.Network”)
sComputer = “.”
sAdminName = GetAdministratorName

On Error Resume Next
Set oUser = GetObject(“WinNT://” & sComputer & “/” & sAdminName & “,user”)
oUser.SetPassword sNewPassword
oUser.SetInfo
‘wscript.echo “setado: ” & sNewPassword
On Error Goto 0

Function GetAdministratorName()
    Dim sUserSID, oWshNetwork, oUserAccount

    Set oWshNetwork = CreateObject(“WScript.Network”)
    Set oUserAccounts = GetObject( _
         “winmgmts://” & oWshNetwork.ComputerName & “/root/cimv2″) _
         .ExecQuery(“Select Name, SID from Win32_UserAccount” _
       & ” WHERE Domain = ‘” & oWshNetwork.ComputerName & “‘”)

    On Error Resume Next
    For Each oUserAccount In oUserAccounts
      If Left(oUserAccount.SID, 9) = “S-1-5-21-” And _
         Right(oUserAccount.SID, 4) = “-500″ Then
        GetAdministratorName = oUserAccount.Name

 ’wscript.echo oUserAccount.Name & “: ” & oUserAccount.SID

        Exit For
      End if
    Next
End Function

Deixe uma resposta

Faça o login usando um destes métodos para comentar:

WordPress.com Logo

You are commenting using your WordPress.com account. Sair / Alterar )

Imagem do Twitter

You are commenting using your Twitter account. Sair / Alterar )

Foto do Facebook

You are commenting using your Facebook account. Sair / Alterar )

Connecting to %s

Seguir

Obtenha todo post novo entregue na sua caixa de entrada.