1

I am attempting to create a batch script that will detect the model of HP laptop, once the model is detected, the script will execute the proper BIOS to the laptop depending the model of the laptop.

So if the laptop is an HP elitebook 840 G1 then install this X BIOS. It laptop is HP elitebook 840 G2 then install Y bios, and so on.

I have found a command :WMIC CSPRODUCT GET NAME this outputs: Name HP EliteBook 840 G1

The script what I have so far is : @echo off

cls

SETLOCAL ENABLEDELAYEDEXPANSION
SET count=1
FOR /F "tokens=*" %%F IN ('WMIC CSPRODUCT GET NAME') DO (
 SET var!count!=%%F
 SET /a count=!count!+1)
 SET v=%var2%
 :;ECHO %var1%
ECHO %var2%
ENDLOCAL

:; Get version number only so drop off HP EliteBook 840
FOR /F "tokens=1-9 delims=K" %%A IN ("%var2%") DO (
    SET V=%%a
    echo %V%
)

The above code is not mine, I got it from:

How to set commands output as a variable in a batch file

This script so far what it does it takes the output of the command WMIC CSPRODUCT GET NAME then stores it in a variable. I am stuck where to proceed after if model is X then install X BIOS.

Please assist me in completing this code. Much appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Are you sure that you want to let the computer choose the bios to update? – NiVeR Jan 15 '18 at 21:32
  • Yes, it is an automated script we need to use to update the bios of the laptops/computers. Right now is a manual work. – NetworkStorm Jan 15 '18 at 22:08
  • That's the point, I wouldn't trust an automatic way to update the BIOS. It is a potentially risky procedure. – NiVeR Jan 15 '18 at 22:10
  • 1
    The entries found in different PC's can be markedly different or completely empty, and therefore the only way to be sure is to know exactly what would be returned on each individual unit before creating your actual bios flash script. Run the WMIC script using /Node and Get all the Values first and also take a look at WMIC BIOS for other options. – Compo Jan 15 '18 at 22:26
  • I am ignorant as to why it is potential risky procedure to semi-automate(one will have to execute the scrip via SCCM or LANDESK) am I missing something as to how organizations update their BIOS is mass? – NetworkStorm Jan 15 '18 at 22:30
  • It is dangerous because you will probably get it wrong and you will turn your device into a door stop or paper weight. HP has tooling you can load onto your HP devices that will recommend the correct drivers for HP devices, it's called HP Support Assistant, I recommend you use that. – jwdonahue Jan 15 '18 at 22:34
  • Well if you need to run the script manually, then you might as well choose the right bios, no? I thought about scheduling a cron to run the scripts and in that case there can be some issues to consider to whether or not the system is ready to perform a bios upgrade (performance, stability, battery etc) – NiVeR Jan 15 '18 at 22:37
  • ok so we have 2500 computers and in wake of meltdown we are prepping to ensure the bios of the computers are up to date. I try see if HP has a tool that will enable multiple bios update at once but no go. – NetworkStorm Jan 15 '18 at 22:54
  • It is very rare to need to update a BIOS, most recommend only to update them when a potentially serious issue requires it. If it isn't broken don't try to fix it. As I said, if you're going to do it anyway, do a run gathering all of the values first, and check each entry before moving forward. – Compo Jan 15 '18 at 23:47
  • @Compo actually, everyone should be watching for bios updates since the beginning of the year when a cache exploit was publicized. Microsoft implemented a partial fix for their OS/Apps, but in most cases, a BIOS update is required to fix it completely. – jwdonahue Jan 16 '18 at 02:44
  • See https://support.hp.com/us-en/document/c05869091. Similar issue affects Dell and anything else that runs x86/64 and some ARM platforms. – jwdonahue Jan 16 '18 at 02:53
  • @jwdonahue, the OP mentioned `meltdown`, I mentioned `update them when a potentially serious issue requires it` and `if it isn't broken don't try to fix it`. _As you know it is broken, and therefore requires fixing!_ I then provided advice on what to do before implementing their intended goal. So given all that, why call me out? Stop being argumentative just for the sake of it; if being here is making you angry then do something about it, just leave me out of your `meltdown`. – Compo Jan 16 '18 at 10:03
  • No! Sorry! I was not angry or trying to be argumentative. My apologies if I came across that way. It was late and I was responding to the "_It is very rare to need to update a BIOS_" statement. Since I had just updated all of mine, I thought I'd point out that now is a very good time to run a full suite of updates. – jwdonahue Jan 16 '18 at 17:19
  • Ok found solution. So the HP utility has some switches, I just create a regular batch script to copy the bios to c:\bin then execute the file from there silent. Everything went smooth. Now I can automate bios update with one click from SCCM batch. I have each script for each model of laptop. What would have been great is to have one script to determine the model of the laptop. But for now this works. Thanks. – NetworkStorm Jan 17 '18 at 20:50

0 Answers0