Fix broken LGHUB backup

This commit is contained in:
Manuel Thalmann 2023-06-09 18:51:20 +02:00
parent 0a4ea5a504
commit 496a55863c

View file

@ -6,18 +6,16 @@ $null = New-Module {
function Invoke-BackupLGHub([Context] $context) {
$hubName = "lghub.exe";
$hubPath = $(Get-Process | Where-Object { [System.IO.Path]::GetFileName($_.Path) -eq $hubName })[0].Path;
$mainProcess = Get-Process | Where-Object {
[System.IO.Path]::GetFileName($_.Path) -eq "$hubName" -and
$_.Parent.ProcessName -eq "explorer"
};
$mainProcesses = Get-Process | Where-Object { @($hubName, "lghub_system_tray.exe") -contains [System.IO.Path]::GetFileName($_.Path) -and $(
$_.Parent.ProcessName -eq "explorer" -or $null -eq $_.Parent) };
$lghub = $mainProcess.Path;
$mainProcess | Foreach-Object { $_.Kill($true) };
$mainProcesses | Foreach-Object { $_.Kill($true) };
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i!settings.db", "-i!icon_cache"));
if ($lghub) {
Start-Process $lghub;
if ($hubPath) {
Start-Process $hubPath;
}
}
}