jantari / LSUClient

Orchestrate driver, BIOS/UEFI and firmware updates for Lenovo computers 👨‍💻
https://jantari.github.io/LSUClient-docs/
MIT License
208 stars 21 forks source link

Forced reboot and not silent installation of a package. How to avoid? #60

Closed migoun closed 1 year ago

migoun commented 1 year ago

Version

1.5.0

Question

After getting Updates with Get-LSUpdate and then installing them with Install-LSUpdate -Package $update -Verbose, this package below was not unattended, the user had to install it manually by clicking through. Also a forced reboot was executed afterwards. How can you prevent this?

Title: ELAN TrackPoint Firmware Update Utility - 10 [64] Type: Firmware Release Date: 03/30/2021 00:00:00 Version: 0.0.0.0

jantari commented 1 year ago

Hi, on what computer model did this occur?

migoun commented 1 year ago

ThinkPad X1 Yoga Gen 4

jantari commented 1 year ago

The installer of that package (ID n2hg705w) is properly declared non-Unattended by LSUClient:

Get-LSUpdate -Model 20QG -All | ? Title -like "*ELAN TrackPoint Firmware*" | Select -ExpandProperty Installer

Unattended     : False
InstallType    : cmd
SuccessCodes   : {0}
InfFile        :
ExtractCommand : n2hg705w.exe /VERYSILENT /DIR=%PACKAGEPATH% /EXTRACT="YES"
Command        : %PACKAGEPATH%\FWUpdate.exe /forcerestart

Have you looked at the README or documentation site at all? How to filter packages that can't be installed unattended or cause reboots is specifically explained in both: https://github.com/jantari/LSUClient#examples-and-tips and https://jantari.github.io/LSUClient-docs/docs/topics/examples/

migoun commented 1 year ago

This will work, but only installs unattended stuff. Other software must be installed with a separated command, and each one is different. F.I.: this Trackpoint software has a silent option: https://download.lenovo.com/pccbbs/mobiles/n2hg705w.txt FWUpdate.exe /silent So in theory, the 'Command' here has to be changed from Command : %PACKAGEPATH%\FWUpdate.exe /forcerestart to Command : %PACKAGEPATH%\FWUpdate.exe /silent

jantari commented 1 year ago

Thanks for pointing that out, I didn't know it can be installed silently at all.

Usually when that's possible Lenovos install commandline defaults to the silent version, like here for example:

...
<Install rc="0,1" type="cmd" default="EN">
    <Cmdline id="EN">%PACKAGEPATH%\dpinst.exe /s /sa</Cmdline>
</Install>
<ManualInstall type="cmd" default="EN">
    <Cmdline id="EN">%PACKAGEPATH%\dpinst.exe</Cmdline>
</ManualInstall>
<Uninstall/>
...

where there's a silent install command used by default and then a separate ManualInstall command. Unfortunately for cases like this where an unattended installation is possible but not done by the Lenovo package, I can't think of a reliable way to detect that and/or find the needed parameters to perform an unattended installation.

I tested searching the Readme of packages for possible silent install commands, but there's often multiple different ones mentioned and there'd be no reliable way to isolate them from the rest of the text.

Quick and dirty search for possible silent commands in package readmes ```powershell Get-LSUpdate -Model 20QG -All | % { if (-not $_.Installer.Unattended) { Write-Host "[$($_.Installer.Unattended)]" $_.ID $_.Title -ForegroundColor Yellow Write-Host "CMD: " $_.Installer.Command -ForegroundColor Yellow $url = $_.Files.Where{$_.Kind -eq 'Readme'}.AbsoluteLocation (iwr $url).content -split "`n" | sls "unattend|silent" -Context 2 | % ToString | % Split -ArgumentList "`n" | % { $rgx = [regex]::match("$_", "[\\\/].*\.exe .*") if ($rgx.Success) { $rgx.Value } } | Write-Host -ForegroundColor Red } } ```

So if it is important that you install this package and do it silently, you could find it by its ID and manually start the installer with the correct parameters instead of using Install-LSUpdate for it.