Refactor LGHUB backup
This commit is contained in:
parent
ba5ced058d
commit
b1c27a982b
1 changed files with 9 additions and 5 deletions
|
@ -6,14 +6,18 @@ $null = New-Module {
|
||||||
|
|
||||||
function Invoke-BackupLGHub([Context] $context) {
|
function Invoke-BackupLGHub([Context] $context) {
|
||||||
$hubName = "lghub.exe";
|
$hubName = "lghub.exe";
|
||||||
$mainProcesses = Get-Process | Where-Object { [System.IO.Path]::GetFileName($_.Path) -eq "$hubName" };
|
|
||||||
$lghub = $mainProcesses[0].Path;
|
$mainProcess = Get-Process | Where-Object {
|
||||||
$hubProcesses = ($mainProcesses + (Get-Process | Where-Object { @("$hubName", "lghub_", "lghub_system_tray.exe") -contains [System.IO.Path]::GetFileName($_.Path) }));
|
[System.IO.Path]::GetFileName($_.Path) -eq "$hubName" -and
|
||||||
$hubProcesses | Foreach-Object { $_.Kill() };
|
$_.Parent.ProcessName -eq "explorer"
|
||||||
|
};
|
||||||
|
|
||||||
|
$lghub = $mainProcess.Path;
|
||||||
|
$mainProcess | Foreach-Object { $_.Kill($true) };
|
||||||
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i!settings.db", "-i!icon_cache"));
|
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i!settings.db", "-i!icon_cache"));
|
||||||
|
|
||||||
if ($lghub) {
|
if ($lghub) {
|
||||||
& "$lghub";
|
Start-Process $lghub;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue