Add scripts for backing up and restoring LGHub
This commit is contained in:
parent
e4b0ffb891
commit
25a43268c9
1 changed files with 76 additions and 8 deletions
|
@ -3,13 +3,81 @@ param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../Scripts/AppAssociations.ps1";
|
& {
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
param ($Parameters)
|
||||||
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
$configPath = "$env:LocalAppData/LGHUB";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
<#
|
||||||
-Installer {
|
.SYNOPSIS
|
||||||
Install-ChocoPackage lghub;
|
Stops the running Logitech G Hub instance.
|
||||||
Remove-DesktopIcon "*G HUB*";
|
#>
|
||||||
};
|
function Stop-LGHub {
|
||||||
|
[OutputType([string])]
|
||||||
|
param()
|
||||||
|
|
||||||
# ToDo: Add restoration
|
$hubName = "lghub_system_tray.exe";
|
||||||
|
|
||||||
|
$candidates = Get-Process | Where-Object { $_.Path -and ((Split-Path -Leaf $_.Path) -eq $hubName) };
|
||||||
|
|
||||||
|
if ($candidates.Count -gt 0) {
|
||||||
|
$lghubPath = $candidates[0].Path;
|
||||||
|
} else {
|
||||||
|
$lghubPath = $null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$mainProcesses = Get-Process | Where-Object {
|
||||||
|
$_.Path -and
|
||||||
|
(@("lghub.exe", "lghub_agent.exe", "lghub_updater.exe", $hubName) -contains (Split-Path -Leaf $_.Path)) -and
|
||||||
|
(($_.Parent.ProcessName -eq "explorer") -or ($null -eq $_.Parent))
|
||||||
|
};
|
||||||
|
|
||||||
|
$null = $mainProcesses | ForEach-Object { $_.Kill($true) };
|
||||||
|
return $lghubPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Edits the Logitech G Hub configuration.
|
||||||
|
#>
|
||||||
|
function Edit-LGHubConfig {
|
||||||
|
param(
|
||||||
|
[scriptblock] $Action
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host "Stopping Logitech G Hub";
|
||||||
|
$path = Stop-LGHub;
|
||||||
|
& $Action;
|
||||||
|
|
||||||
|
if ($path) {
|
||||||
|
Write-Host "Restarting Logitech G Hub";
|
||||||
|
Start-Process $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @Parameters `
|
||||||
|
-Installer {
|
||||||
|
Install-ChocoPackage lghub;
|
||||||
|
Remove-DesktopIcon "*G HUB*";
|
||||||
|
} `
|
||||||
|
-UserBackup {
|
||||||
|
param(
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
Edit-LGHubConfig {
|
||||||
|
Add-BackupArtifacts -User $Arguments.Name -Source $configPath -Path "LGHub" `
|
||||||
|
-Include @("settings.db", "icon_cache")
|
||||||
|
};
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param(
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
Edit-LGHubConfig {
|
||||||
|
Expand-BackupArtifacts -User $Arguments.Name -Path "LGHub" -Target $configPath;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
||||||
|
|
Loading…
Reference in a new issue