Script activation OEM Windows
Bonjour,
travaillant avec une quinzaine de types d'ordinateurs (ACER, HP, DELL, LENOVO), je cherche à automatiser l'activation avec les clés OEM à partir d'une image système unique.
Je joins le script fonctionnel réalisé jusqu’à présent mais la détection des marques retourne parfois la marque de la carte mère et non celle du fabriquant. De plus, cela demande une MAJ à chaque nouvelle série d'ordinateur (2 fois par ans) et la gestion des séries que des collègues utilisent mais que je n'ai pas reçu.
Le script se base sur un fichier liste au format csv contenant la marque et la clé oem ainsi qu'un dossier "XRM-MS" contenant les fichier xrm-ms des marques.
J'aimerais une revue du script afin d'améliorer le code et des propositions si des meilleurs solutions sont envisageables.
Merci.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
On Error Resume Next
Dim filesys, readfile, contents, cpt, tableau
strComputer = "."
marque = "0"
'Fonction récupération adresse dossier
Function GetPath()
Dim path
path = WScript.ScriptFullName
GetPath = Left(path, InStrRev(path, "\"))
End Function
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard")
For Each objItem in colItems
marque = UCase(objItem.Manufacturer)
Next
Set oShell = WScript.CreateObject("WScript.Shell")
set filesys = CreateObject("Scripting.FileSystemObject")
set readfile = filesys.OpenTextFile(getpath() & "LicencesWin7.csv", 1, false)
do while readfile.AtEndOfStream=false
contents = readfile.ReadLine
tableau = split(contents,";")
if marque = tableau(0) then
fichierOEM = tableau(1)
licence = tableau(2)
end if
loop
readfile.close
If IsEmpty(fichierOEM) then
btn = oShell.Popup("Aucune licence trouvée", 10, "Licence", &H30 + &H1000)
wscript.quit
else
btn = oShell.Popup("Marque : " & marque & vbCrLf & vbCrLf & "Fichier : "_
& fichierOEM & vbCrLf & vbCrLf & "Clé : " & licence, 20, "Information licence", &H40 + &H1000)
cmd0 = "cmd /C slmgr -ilc " & getpath() & "XRM-MS\" & fichierOEM
'oShell.run cmd0
WScript.Sleep 10000
cmd1 = "cmd /C slmgr -ipk " & licence
'oShell.run cmd1
end if |