The current manual process for obtaining all drivers for a model of Lenovo laptop is;
- Browse the Lenovo website
- Download each individual driver
- Extract the driver
- Import it into SCCM.
What a pain. Takes hours.
This post is an adaptation of an idea I found here.
The idea is to try and automate some of the process. Instead of using Kenny Buntinx’s recommendation of running the Lenovo thininstaller programme from within a task sequence after downloading all drivers via the Update retriever, I have written a script that extracts the executables.
At the end, the process looks something like this;
- Use Lenovos Update Retriever to pull down all drivers for your model of laptop.
- Run my extraction script which parses the downloads from the Update Retriever and then extracts all drivers to a destination path.
- Import the drivers into SCCM or MDT
This reduces the time to obtain drivers for a model of laptop to less than an hour.
Follow this steps;
- Download the Lenovo Update Retriever from here and install it
- Run the software;
- Set your repository directory (Where you want to place your updates)
- Important: Set the ‘Status’ drop down list to ‘Active’. The entire process will not work correctly unless you change this!
- Click ‘continue’ to begin’.
- Add the model of laptop you require. Note that this requires the 4 digit code model code, not the model type.
- Edit my script;
- Change the ‘objStartFolder’ variable to point towards where you downloaded the updates to in the previous step.
- Change the ‘ModelType’ and ‘PackagePathRoot’ variables to suit your needs. These determine where you want to extract the drivers to.
- Run the script using cscript from a command line.
- Import the drivers into SCCM.
The script works by reading the XML file provided with each update. It searches for the ‘ExtractCommand’ element and then runs it for each update. The script is rather crude at the moment and needs tidying up. Please feel free to fix it up and improve it…It needs some TLC!
The code (WordPress seems to strip out the formatting..);
' ExtractDriversSet objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")objStartFolder = "D:\Lenovo_Repository"
ModelType = "T410"
PackagePathRoot = "C:\" & ModelType & "\"Dim filePath
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
filePath=Subfolder.Path
WScript.Echo "---------------------------------------------------------"
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
If LCase(Right(Cstr(objFile.Name), 3)) = "xml" Then
getAttributes2(ObjFile.Path)
End If
Next
Wscript.Echo
ShowSubFolders Subfolder
Next
End SubSub getAttributes2(fileToSearch)
Dim xmlDoc, objNodeListSet xmlDoc = CreateObject("Msxml2.DOMDocument")
WScript.Echo "Processing: " & fileToSearch
xmlDoc.load(fileToSearch)
Set objNodeList = xmlDoc.getElementsByTagName("Package")name = objNodeList.item(0).getAttribute("name")
Set objNodeList = xmlDoc.getElementsByTagName("Desc")
If objNodeList.length > 0 Then
desc2=objNodeList.item(0).textElse
WScript.echo chr(34) & "ExtractCommand" & chr(34) & " field not found."
End IfWScript.Echo "Description: " & desc2
Set objNodeList = xmlDoc.getElementsByTagName("ExtractCommand")
If objNodeList.length > 0 then
For each x in objNodeList
Extract=x.text
fullExtract = filePath & "\" & Extractdesc3=Replace(desc2,"/","_")
replacedExtract=Replace(fullExtract,"%PACKAGEPATH%","""" & PackagePathRoot & desc3 & """")
splitText = Split(replacedExtract," ")
If objFSO.FileExists(splitText(0)) Then
WScript.Echo vbCRLF & "Located Executable: " & splitText(0)
WScript.Echo "Running Extraction: " & replacedExtract
WshShell.Run replacedExtract,0,TrueElse
WScript.Echo "Found NOT file: " & splitText(0)
End If
Next
Else
WScript.echo chr(34) & "ExtractCommand" & chr(34) & " field not found."
End IfEnd Sub
Let me know your thoughts, I would be interested in tarting this process up a bit.
Richard
Thank you so much for putting this together! What a life saver. We’re strictly a Dell shop, but our hands were tied when a client of ours insisted upon buying a bunch of Lenovo Thinkpad X220′s. After having downloaded all the drivers via the Update Retriever I soon realized that the format they downloaded in wasn’t ideal for our MDT2010 setup. This script will make deployment a breeze! I really can’t thank you enough
~Drew
Hi Drew,
Your welcome. I’m glad it proved useful to someone!
Richard
This script looks awesome, and it’s just what I was looking for! We’re in the process of moving our company to an all-Lenovo operation, and (lucky me!) have been put in charge of sorting out all the SCCM imaging for that. This will be immensely helpful! Thanks!
Wow! What a smart script, very impressive. This did exactly what I was looking for, THANK YOU SO MUCH!!!
How do you run this script in cscript?
NVM vbs extension
WOW a life safer THANK YOU SO MUCH!!!
This is beautiful.
Big big big big thanks to you! This script safes millions of hours. Thank you!