'Batch - Check Dell bios version and update script
I'm creating a script to automatic update BIOS firmware for our Dell PC. We have multiple model here, so I need to check the model
C:\Users\me>wmic csproduct get name
Name
OptiPlex 3020
And also bios version
C:\Users\me>wmic bios get smbiosbiosversion
SMBIOSBIOSVersion
A09
Now I will put the bios updater somewhere on our network with filename format model_version.exe.
How should I do to get the model and version in to 2 variables and in the end I just run
//path/to/the/updater/"%model%_%version%.exe" /s /r
to update the bios automatically, if the PC already on the latest bios version, just skip the script?
Thank a lot for your help.
Solution 1:[1]
I recently had this same issue, needing to update a bunch of Acer laptops BIOS to fix the trackpads. Here is the solution I came up with, using the linked Batch file set wmi output as a variable from JosefZ's comment on your question.
By using /value switch of wmic we can get the wmic output on one line and then use 'for' with delims to tokenize it (split into two variables) and store the 2nd token as our desired variable.
Check if the file exists, then pass through to the "start" command so the bat file won't exit until after it has run the updater. (This is useful if combining with pushd to access a network path so the drive letter doesn't drop out)
for /f "tokens=2 delims==" %%f in ('wmic csproduct get name /value ^| find "="') do set "model=%%f"
for /f "tokens=2 delims==" %%f in ('wmic bios get smbiosbiosversion /value ^| find "="') do set "version=%%f"
IF EXIST "\\path\to\the\updater\%model%_%version%.exe" start "" /WAIT "\\path\to\the\updater\%model%_%version%.exe" /s /r
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
