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

24 lines
687 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-08 16:04:03 +00:00
$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) };
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) {
2023-06-08 16:04:03 +00:00
Start-Process $lghub;
2023-06-08 00:28:33 +00:00
}
}
2023-06-07 18:56:40 +00:00
}