Fix broken LGHUB backup

This commit is contained in:
Manuel Thalmann 2023-06-09 18:51:20 +02:00
parent 3db7fb1ff9
commit 73a070e286

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;
}
}
}