Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

mot de passe admin local

1 réponse
Avatar
Rafi
Hello,
Voici un script afin de modifier le mot de passe de l'administrator local
sur des PC à distance :
"
Detailed Information
Platforms(s): Windows 2000/XP, 2000/2003 Server

There are a few things in the script that will need to be changed.
src="c:\pclist.txt"
This is the path to the computers that will have its password changed. You
can modify this if needed.

Set noton = fso.CreateTextFile("c:\logs\log.txt")
This is the path to the log file, you can leave it here or change to desired
path.

Set user = GetObject("WinNT://" & temp & "/administrator,user")
This is the account that will have its password changed. If your local admin
account is named something different you will need to change it.

END OF HELP INFO FOR THE SCRIPT.

Copy and paste the code below into a text file and save as filename.vbs
'******************************************************
'Title: Change Local Admin Password
'Description: Changes local admin password on multiple computers.
'********************************************************
Dim fso, user, ts, temp, src
src = "c:\pclist.txt" '** text file list of computer names
Set fSO = CreateObject("Scripting.FileSystemObject")
Set noton = fso.CreateTextFile("c:\logs\log.txt") ' error log
Set ts = fso.OpenTextFile(src,1)

Const cTitlebarMsg = "Local Administrator Password Change Tool" ' Custom
title bar
password = InputBox("Enter new admin password.", cTitlebarMsg)

If Len(password) = 0 Then 'Checks if inputbox = 0
WScript.Quit
End If

Do Until ts.AtEndOfStream ' Start of do loop
on error resume next
temp = ts.ReadLine

Set user = GetObject("WinNT://" & temp & "/administrator,user") ' local
account to change password

'***********Start error checking write to log file***********
If err.number <> 0 Then
noton.writeline strmachine & VBCrLf & _
"Description: " & err.description & VBCrLf & _
"Source: " & err.source & VBCrLf & _
"Number: " & err.number & VBCrLf & _
"==============================================="
err.clear

Else
noton.writeline strmachine & VBCrLf & _
"done" & VBCrLf & _
"==============================================="
End If
'*******************End error checking*********************

user.setpassword password
user.setinfo
Loop

Wscript.echo "Done"
"

Afin de l'améliorer, pourriez vous me dire comment modifier les inscriptions
dans le fichiers "log.txt" car pour l'instant je n'arrive à avoir que ceci:

Description:
Source:
Number: -2147024843
===============================================

et j'aimerais bien que le nom du PC qui a eu cette erreur soit aussi affiché
; et aussi si les informations lors d'une erreur sont bien pertinante :

If err.number <> 0 Then
noton.writeline strmachine & VBCrLf & _
"Description: " & err.description & VBCrLf & _
"Source: " & err.source & VBCrLf & _
"Number: " & err.number & VBCrLf & _

Pourriez-vous me dire aussi si on peut améliorer la sécurité de l'envoi de
ce mot de passe qui doit se faire en clair...

Merci d'avance pour vos informations

Rafi

1 réponse

Avatar
MC
Bonjour !

Va là :
http://www.microsoft.com/technet/sysinternals/utilities/sysinternalssuite.mspx

et télécharge pspasswd


Utilisation :

pspasswd [[Ordinateur_Distant | Domaine] [-u Nom_Utilisateur [-p
Mot_De_Passe]]] Nom_Utilisateur [Nouveau_Mot_De_Passe]
-u : spécifie un nom d'utilisateur afin de pouvoir se connecter sur une
machine distante.
-p : spécifie un mot de passe pour le nom d'utilisateur indiqué.




Et que la Force des batchs soit avec toi !







--
@-salutations

Michel Claveau