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 |
Partager