PortValhalla/scripts/Windows/Software/LGHub/Manage.ps1

20 lines
783 B
PowerShell
Raw Normal View History

2023-06-07 18:56:40 +00:00
. "$PSScriptRoot/../../Scripts/Context.ps1";
2023-06-08 00:28:33 +00:00
$null = New-Module {
$path = "$env:LOCALAPPDATA/LGHUB";
$softwareName = "LGHub";
function Invoke-BackupLGHub([Context] $context) {
$hubName = "lghub.exe";
$mainProcesses = Get-Process | Where-Object { [System.IO.Path]::GetFileName($_.Path) -eq "$hubName" };
$lghub = $mainProcesses[0].Path;
2023-06-08 00:29:09 +00:00
$hubProcesses = ($mainProcesses + (Get-Process | Where-Object { @("$hubName", "lghub_", "lghub_system_tray.exe") -contains [System.IO.Path]::GetFileName($_.Path) }));
2023-06-08 00:28:33 +00:00
$hubProcesses | Foreach-Object { $_.Kill() };
2023-06-08 00:29:09 +00:00
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i!settings.db", "-i!icon_cache"));
2023-06-08 00:28:33 +00:00
if ($lghub) {
& "$lghub";
}
}
2023-06-07 18:56:40 +00:00
}