Refactor LGHUB backup

This commit is contained in:
Manuel Thalmann 2023-06-08 18:04:03 +02:00
parent ba5ced058d
commit b1c27a982b

View file

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