' Script de renommage de nom de compte ' JCB © 2010 ' Ajout message d'erreur MD 2011 Set args = Wscript.Arguments nbargs=args.count If nbargs<>2 then wscript.echo "Il faut fournir 2 paramêtres !!!" wscript.quit End If oldname=Trim(args(0)) newname=Trim(args(1)) If oldname="" or newname="" or StrComp(oldname,newname,vbTextCompare)=0 Then wscript.echo "Les 2 Paramêtres sont identiques !!!" wscript.quit End If retour=false Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colAccounts = objWMIService.ExecQuery( _ "Select * From Win32_UserAccount Where " & _ "LocalAccount = True And Name ='" & oldname & "'") For Each objAccount in colAccounts retour=true objAccount.Rename newname Next If Not retour Then wscript.echo "Le compte utilisateur n'a pas été trouvé !!!"