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

22 lines
817 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";
2023-06-09 16:51:20 +00:00
$hubPath = $(Get-Process | Where-Object { [System.IO.Path]::GetFileName($_.Path) -eq $hubName })[0].Path;
2023-06-08 16:04:03 +00:00
2023-06-09 16:51:20 +00:00
$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) };
2023-06-08 16:04:03 +00:00
2023-06-09 16:51:20 +00:00
$mainProcesses | Foreach-Object { $_.Kill($true) };
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
2023-06-09 16:51:20 +00:00
if ($hubPath) {
Start-Process $hubPath;
2023-06-08 00:28:33 +00:00
}
}
2023-06-07 18:56:40 +00:00
}