Add a script for restoring LGHub
This commit is contained in:
parent
fb3ec54c13
commit
9aa9ad4558
1 changed files with 23 additions and 4 deletions
|
@ -3,19 +3,38 @@
|
|||
$null = New-Module {
|
||||
$path = "$env:LOCALAPPDATA/LGHUB";
|
||||
$softwareName = "LGHub";
|
||||
[string]$lghubPath;
|
||||
|
||||
function Backup-LogitechGHUB([Context] $context) {
|
||||
$hubName = "lghub.exe";
|
||||
$hubPath = $(Get-Process | Where-Object { [System.IO.Path]::GetFileName($_.Path) -eq $hubName })[0].Path;
|
||||
function Get-LogitechGHUBName() {
|
||||
return "lghub.exe";
|
||||
}
|
||||
|
||||
function Stop-LogitechGHUB() {
|
||||
[OutputType([string])]
|
||||
param();
|
||||
$hubName = Get-LogitechGHUBName;
|
||||
$lghubPath = $(Get-Process | Where-Object { [System.IO.Path]::GetFileName($_.Path) -eq $hubName })[0].Path;
|
||||
|
||||
$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) };
|
||||
|
||||
$mainProcesses | Foreach-Object { $_.Kill($true) };
|
||||
$null = $mainProcesses | Foreach-Object { $_.Kill($true) };
|
||||
return $lghubPath;
|
||||
}
|
||||
|
||||
function Backup-LogitechGHUB([Context] $context) {
|
||||
$hubPath = Stop-LogitechGHUB;
|
||||
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i!settings.db", "-i!icon_cache"));
|
||||
|
||||
if ($hubPath) {
|
||||
Start-Process $hubPath;
|
||||
}
|
||||
}
|
||||
|
||||
function Restore-LogitechGHUB([Context] $context) {
|
||||
choco install -y lghub;
|
||||
$hubPath = Stop-LogitechGHUB;
|
||||
$context.Restore($context.SoftwareArchive($softwareName), $path);
|
||||
Start-Process $hubPath;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue