Lenovo BIOS update script
This script can be used in a task sequence (MDT or SCCM) to upgrade the BIOS on Lenovo PCs eg. during Operating System Deployment.In MDT I have imported the script as an application. The firmware files must be located with the script source folder in sub folders e.g. “T460” .
The install command is “cscript.exe LenovoBIOS.vbs” (name the script file LenovoBIOS.vbs).
Then I install the application as a step in my task sequence. The installation step should be placed after the computer has applied the operating system and has re-booted into full Windows (not WinPE). Since the logic for selecting the right firmware is in the script, i don’t have any conditions on the task sequence step. Put a Restart Computer step right after the BIOS upgrade step. The actual upgrade of the firmware takes place during the re-boot.
You may have to resume BitLocker after the BIOS upgrade and subsequent re-boot (Windows 7). Please test thoroughly before deploying to production.
EDIT (2020-05): The script below is quite old now, so please remember to update it with the latest BIOS version numbers e.g. “G1ETB1W” as specified by Lenovo.
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
'****************************************************** ' ' ' Script purpose: ' Update BIOS on Lenovo desktop/laptops ' ' '****************************************************** Dim StrModel, StrCurrentBIOS Dim oWSHShell: Set oWSHShell = CreateObject("WScript.Shell") Dim oFSO: Set oFSO = CreateObject("Scripting.FileSystemObject") Dim StrCurPath: StrCurPath = oWSHShell.CurrentDirectory GetData() '--------======= BIOS Update Information starts here =======-------- If StrModel = "THINKPAD HELIX" And StrCurrentBIOS < "GFET54WW" Then PerformUpdateLaptops("HELIX") End If If StrModel = "THINKCENTRE M92P" And StrCurrentBIOS < "9SKT95A" Then PerformUpdateDesktops "M92P","afuwin.exe image9s.cap /p /n /sp /q" End If If StrModel = "THINKCENTRE M93P" And StrCurrentBIOS < "FBKTC9A" Then PerformUpdateDesktops "M93P","afuwin.exe IMAGEFB.ROM /p /n /sp /q" End If If StrModel = "THINKCENTRE M700" And StrCurrentBIOS < "FWKT57A" Then PerformUpdateDesktops "M700","afuwin.exe imageFW.rom /p /n /sp /q" End If If StrModel = "THINKPAD P50" And StrCurrentBIOS < "N1EET57W" Then PerformUpdateLaptops("P50") End If If StrModel = "THINKPAD T420S" And StrCurrentBIOS < "8CET63WW" Then PerformUpdateLaptops("T420s") End If If StrModel = "THINKPAD T430" And StrCurrentBIOS < "G1ETB1W" Then PerformUpdateLaptops("T430") End If If StrModel = "THINKPAD T430S" And StrCurrentBIOS < "G7ETA5W" Then PerformUpdateLaptops("T430S") End If If StrModel = "THINKPAD T440" And StrCurrentBIOS < "GJET90W" Then PerformUpdateLaptops("T440") End If If StrModel = "THINKPAD T450" And StrCurrentBIOS < "JBET64WW" Then PerformUpdateLaptops("T450") End If If StrModel = "THINKPAD T450S" And StrCurrentBIOS < "JBET65WW" Then PerformUpdateLaptops("T450s") End If If StrModel = "THINKPAD T460" And StrCurrentBIOS < "R06ET49W" Then PerformUpdateLaptops("T460") End If If StrModel = "THINKPAD T460S" And StrCurrentBIOS < "N1CET58W" Then PerformUpdateLaptops("T460s") End If If StrModel = "ThinkPad T470 W10DG" And StrCurrentBIOS < "N1QET55W" Then PerformUpdateLaptops("T470") End If If StrModel = "THINKPAD T530" And StrCurrentBIOS < "G4ETA6W" Then PerformUpdateLaptops("T530") End If If StrModel = "THINKPAD X1 CARBON" And StrCurrentBIOS < "G6ETB4W" Then PerformUpdateLaptops("X1CARBON") End If If StrModel = "THINKPAD X230" And StrCurrentBIOS < "G2ETA6W" Then PerformUpdateLaptops("X230") End If If StrModel = "THINKPAD X240" And StrCurrentBIOS < "GIET86W" Then PerformUpdateLaptops("X240") End If If StrModel = "THINKPAD X250" And StrCurrentBIOS < "N10ET46W" Then PerformUpdateLaptops("X250") End If If StrModel = "THINKPAD X260" And StrCurrentBIOS < "R02ET56W" Then PerformUpdateLaptops("X260") End If If StrModel = "ThinkPad X270 W10DG" And StrCurrentBIOS < "R0IET40W" Then PerformUpdateLaptops("X270") End If '--------======= BIOS Update Information ends here =======-------- Sub PerformUpdateLaptops(StrFolderName) 'wscript.echo "Starting update of" & StrModel ChangeBitLocker "Disable" oWSHShell.CurrentDirectory = StrCurPath & "\" & StrFolderName If oFSO.FileExists("phlash.ini") Then oFSO.DeleteFile "phlash.ini" oWSHShell.Run "WINUPTP.EXE -s",0,true ChangeBitLocker "Enable" WScript.Quit 3010 End Sub Sub PerformUpdateDesktops(StrFolderName, StrCommand) ChangeBitLocker "Disable" oWSHShell.CurrentDirectory = StrCurPath & "\" & StrFolderName If oFSO.FileExists("phlash.ini") Then oFSO.DeleteFile "phlash.ini" oWSHShell.Run StrCommand,0,true ChangeBitLocker "Enable" WScript.Quit 3010 End Sub Sub GetData() For Each oSystem in GetObject("winmgmts:").InstancesOf ("Win32_ComputerSystemProduct") StrModel = UCase(Trim(UCase(oSystem.Version))) Next For Each oBIOS in GetObject("winmgmts:").InstancesOf ("Win32_BIOS") StrCurrentBIOS = Trim(Left(UCase(oBIOS.SMBIOSBIOSVersion),8)) Next 'wscript.echo StrModel 'wscript.echo StrCurrentBIOS End Sub Sub ChangeBitLocker(State) 'Change BitLocker state and only allow reenabling if not running in TS. On Error Resume Next If State = "Enable" Then Set OSD = CreateObject("Microsoft.SMS.TSEnvironment") If Err.Number = 0 Then 'Running in TS Exit Sub Else oWSHShell.Run "Manage-BDE.exe -Protectors -Enable C:",0,true End If Else oWSHShell.Run "Manage-BDE.exe -Protectors -Disable C:",0,true End If End Sub |
10 Comments
Join the discussion and tell us your opinion.
Hi WinTech, I was hoping you can help me with the following request. I’m in the process of trying to automate and silently update all of our Lenovo systems BIOS via the MDT OS Deployment process. I’ve been researching this topic and testing several ways but I’ve only manage to get it working by adding the BIOS folder for each model as an application in MDT. I then add it to my task sequence as an ( Install application) which the application copies the BIOS folder from MDT to the local system into ( C:\Windows\Temp ) Then in my task sequence ( Install application) I’ve created two WMI Query, one for BIOS Version and one for models. If all conditions are true, it runs a batch with the corresponding silent switches. Inside the batch file I’m using the following information below. I saw your script and it seems more unify and a one stop shop option as a single process. Can you please guide me on how to use this in MDT… I’m assuming everything goes inside one folder and you are running it within a task sequence. I’m not a big scripter as I’m still in the learning curve. Can you please assist me with this request.
Thanks in advance
Erik
@Echo off
REM Copy_M92p_BIOS_Files
REM Upgrade_M92p_BIOS
xcopy.exe “%deployroot%\Applications\ThinkCentre M92p BIOS V-9AA\*.*” “C:\Windows\Temp\M92p” /Q /H /E /I /Y
timeout /t 5
Echo Updating M92p BIOS…
c:
cd Windows
cd Temp
cd M92p
start /WAIT wflash2.exe IMAGE9S.CAP /bb /rsmb /quiet
Echo Installation completed!
Hi Erik
Thanks for commenting 🙂
I have added som more info to the post. Hope that was what you were looking for. There is no need to manually download the firmware upgrade files to c:\windows\temp\.
Br
Peter
Hi Peter, thank you for the prompt response and all the screenshots and information to use in MDT. I followed your instructions to the “T” however; the script seems to run for a second then it just disappears. The only line item I changed was adding the latest BIOS version number in the script to reflect the most current version for my test M92P system as shown her below.
If StrModel = “THINKCENTRE M92P” And StrCurrentBIOS < "9SKT9AA" Then
PerformUpdateDesktops "M92P","afuwin.exe image9s.cap /p /n /sp /q"
End If
I had one quick concern, how does your script logic determine if the system already has the latest BIOS update and skip the process? By the way, I also deleted the Bitlocker portion at the end of the script as I have it already being process using the (Invoke-MbamClientDeployment.ps1) from Microsoft and it works great for Win 7 and Win 10. One thing I did was to revise my current BIOS update batch file by using the switches for the (AFUWIN.EXE) that I saw on your script, it actually works even better than using the switches for the (wflash2.exe) I had originally. The BIOS Updates actually is being process within the OS environment vs. on the reboot stage. I'm including the updated batch file information for your review, this is actually working perfect in the OS environment. I still would like to use your (LenovoBIOS.vbs) but I can't seem to get it working. If possible can you e-mail me directly to (erikmiranda@bayviewassetmanagement.com) so I don't overload this comment and post area with several screenshots.
Thanks again
Erik
—————————————————————————————-
@Echo off
REM Copy_M92p_BIOS_Files
REM Upgrade_M92p_BIOS
xcopy.exe "%deployroot%\Applications\ThinkCentre M92p BIOS V-9AA\*.*" "C:\Temp\M92p" /Q /H /E /I /Y
timeout /t 5
Echo Updating M92p BIOS…
c:
cd Temp
cd M92p
start /WAIT AFUWIN.EXE IMAGE9S.CAP /P /N /SP /R
Exit
Echo Installation completed!
——————————————————————————————-
Hi Peter, just in case you can’t reply to my e-mail the following is what I have so far in my MDT as per your instructions
Script and BIOS folder has been created and imported as and (Application along with the command)
cscript.exe LenovoBIOS.vbs
.\Applications\Lenovo BIOS Upgrade
The folder along with the script is created in (C:\DeploymentShare\Applications\Lenovo BIOS Upgrade) inside it contains the script and BIOS folder
LenovoBIOS.vbs
M92P
Added the application as in the task sequence right after the OS boots for the first time under (State Restore)
Lenovo BIOS Upgrade
Restart computer
Hi Erik
I sent you an email. Did you get it ?
Hi Peter, I did replied to your last -mail and I also included some additional information regarding Lenovo BIOS updates for your review. Not sure if you got all three e-mails I sent. I also wanted to ask you if anyone has access to post screenshots on your comments section on this page. I was trying to add some the other days, but was not able to do so.
Again, thank you for all your help
Erik
The BIOS I download for the M92P does not contain the afuwin.exe. Do I just download the latest from https://www.wimsbios.com/amiflasher.jsp? The particular one I am looking at contains AFUDOS.exe, AMIDEDOS, AUTOEXEC.BAT, changes.txt, ChgLogo.exe, CompDos.exe, flash2.exe, IMAGE9S.CAP, logo.bat, readme.txt. I have downloaded all the available firmware (ISO,ZIP,EXE) from https://support.lenovo.com/us/en/downloads/ds029265 and none seem to have the afuwin.exe.
Thanks
Hi Mike
Thanks for commenting! I just chose the one called “Flash UEFI BIOS update (Flash from operating system version)”. Here’s the link: https://download.lenovo.com/pccbbs/thinkcentre_bios/9sjy9ausa.exe. It contains both AFUWIN.EXE and AFUWINx64.EXE.
Br Peter
Hi, First let me say thank you, this solution works a treat on the laptops I’ve got, noticed you didn’t list any Desktops in your script, what should be the command to run for desktops, PerformUpdateDesktops, laptops have oWSHShell.Run “WINUPTP.EXE -s”,0,true but desktops just oWSHShell.Run StrCommand,0,true
Hi Ricky
Sorry for the late reply. There are a few desktops in the script, e.g. M92P. The command for desktops is specified as a parameter when calling the function. For the M92P model, it is “afuwin.exe image9s.cap /p /n /sp /q”.