Command line

Script for BIOS updates (multi-version):

echo ---------Bios update ----------->>C:\pnpDrivers\BIOS.log
for /f "delims=" %%D in ('dir /a:d /b %~dp0') do set BIOSFILE=%%D
set Fullpath=%~dp0%BIOSFILE%
echo ---------Fullpath = %Fullpath% ----------->>C:\Drivers\BIOS.log

cd "%Fullpath%"
del "%Fullpath%\HpFirmwareUpdRec.log" /F /Q

echo 3010:SUCCESS:REBOOT=A restart is required to complete the install>>C:\Drivers\BIOS.log
echo 1602:CANCEL:NOREBOOT=The install is cannot complete due to a dependency>>C:\Drivers\BIOS.log
echo 273:CANCEL:NOREBOOT=Flash did not update because update is same BIOS version>>C:\Drivers\BIOS.log
echo 282:CANCEL:NOREBOOT=Flash did not update because update is an older BIOS version>>C:\Drivers\BIOS.log

if EXIST "%Fullpath%\HpFirmwareUpdRec.exe" echo HpFirmwareUpdRec.exe>>C:\Drivers\BIOS.log
if EXIST "%Fullpath%\HpFirmwareUpdRec.exe" start /wait "BIOS" "%Fullpath%\HpFirmwareUpdRec.exe" -s -r -h -b -f"%Fullpath%
if EXIST "%Fullpath%\HPBIOSUPDREC.exe" echo HPBIOSUPDREC.exe>>C:\Drivers\BIOS.log
if EXIST "%Fullpath%\HPBIOSUPDREC.exe" start /wait "BIOS" "%Fullpath%\HPBIOSUPDREC.exe" -s -b -r -a

set codesortie=%ERRORLEVEL%
echo %codesortie%>>C:\Drivers\BIOS.log
if %codesortie% EQU 3010 exit /B 0

Error 260 with the HP_TOOLS partition

In previous BIOS versions, the partition had to be created before updating the BIOS. However, in current versions, detection causes issues, leading to the need to delete the partition.

In previous BIOS versions, the partition had to be created before updating the BIOS. However, in current versions, detection causes issues, leading to the need to delete the partition.

$Partitions = Get-Partition
$volumes    = Get-Volume

#detectC
$PartLettreC = 99
Foreach($Partition in $Partitions) {
    $Letterpart = $Partition.DriveLetter
    $Numberpart = $Partition.PartitionNumber
  $sizepart   = $Partition.Size
  $TypePart   = $Partition.Type
    If ($Letterpart -eq "C") { $PartLettreC = $Numberpart }
}

#detectD
$PartLettreD = 99
Foreach($Partition in $Partitions) {
    $Letterpart = $Partition.DriveLetter
    $Numberpart = $Partition.PartitionNumber
  $sizepart   = $Partition.Size
  $TypePart   = $Partition.Type
    If ($Letterpart -eq "D") { $PartLettreD = $Numberpart }
}

#detect WinRE + HP-Tools
Foreach($Partition in $Partitions) {
    $Letterpart = $Partition.DriveLetter
    $Numberpart = $Partition.PartitionNumber
  $sizepart   = $Partition.Size
  $TypePart   = $Partition.Type

  If (($Numberpart -ne "1") -and ($Letterpart -ne "C") -and ($Letterpart -ne "D")) {
    write-host "----------------------------------"
    write-host "TypePart=$TypePart"
    write-host "sizepart=$sizepart"
    write-host "Numberpart=$Numberpart"

    if (($sizepart -le 6442450944) -and ($Numberpart -eq "3") -and ($TypePart -match "Unknown")) {
      write-host "Remove WinRE partition"
      Remove-Partition -DiskNumber 0 -PartitionNumber $Numberpart -confirm:$False
    }
    if (($sizepart -le 6442450944) -and ($Numberpart -eq "3") -and ($TypePart -match "FAT32 XINT13")) {
      write-host "Remove HP_Tools partition"
      Remove-Partition -DiskNumber 0 -PartitionNumber $Numberpart -confirm:$False
    }
  }
}

$size = (Get-PartitionSupportedSize -DiskNumber 0 -PartitionNumber $PartLettreC)
Resize-Partition -DiskNumber 0 -PartitionNumber $PartLettreC -Size $size.SizeMax -ErrorAction SilentlyContinue

if($PartLettreD -ne 99) {
  $size = (Get-PartitionSupportedSize -DiskNumber 0 -PartitionNumber $PartLettreD)
  Resize-Partition -DiskNumber 0 -PartitionNumber $PartLettreD -Size $size.SizeMax -ErrorAction SilentlyContinue
}


0 commentaire

Laisser un commentaire

Emplacement de l’avatar

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.