diff --git a/scripts/Windows/Software/LGHub/Manage.ps1 b/scripts/Windows/Software/LGHub/Manage.ps1 index ad5461f3..f5037392 100644 --- a/scripts/Windows/Software/LGHub/Manage.ps1 +++ b/scripts/Windows/Software/LGHub/Manage.ps1 @@ -1,7 +1,19 @@ . "$PSScriptRoot/../../Scripts/Context.ps1"; -$path = "$env:LOCALAPPDATA/LGHUB"; -$softwareName = "LGHub"; -function Invoke-BackupLGHub([Context] $context) { - $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i!settings.db*", "-i!icon_cache")); +$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; + $hubProcesses = ($mainProcesses + (Get-Process | Where-Object { @("$hubName", "lghub_agent.exe", "lghub_system_tray.exe") -contains [System.IO.Path]::GetFileName($_.Path) })); + $hubProcesses | Foreach-Object { $_.Kill() }; + $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i!settings.db*", "-i!icon_cache")); + + if ($lghub) { + & "$lghub"; + } + } } diff --git a/scripts/Windows/Software/ManiaPlanet/Manage.ps1 b/scripts/Windows/Software/ManiaPlanet/Manage.ps1 index bc433fc1..1761e90e 100644 --- a/scripts/Windows/Software/ManiaPlanet/Manage.ps1 +++ b/scripts/Windows/Software/ManiaPlanet/Manage.ps1 @@ -1,7 +1,10 @@ . "$PSScriptRoot/../../Scripts/Context.ps1"; -$path = "$HOME/Documents/ManiaPlanet"; -$softwareName = "ManiaPlanet"; -function Invoke-BackupManiaPlanet([Context] $context) { - $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"")); +$null = New-Module { + $path = "$HOME/Documents/ManiaPlanet"; + $softwareName = "ManiaPlanet"; + + function Invoke-BackupManiaPlanet([Context] $context) { + $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"")); + } } diff --git a/scripts/Windows/Software/PuTTY/Manage.ps1 b/scripts/Windows/Software/PuTTY/Manage.ps1 index 716bb7e4..5d5d40bd 100644 --- a/scripts/Windows/Software/PuTTY/Manage.ps1 +++ b/scripts/Windows/Software/PuTTY/Manage.ps1 @@ -1,16 +1,19 @@ . "$PSScriptRoot/../../Scripts/Context.ps1"; -$softwareName = "PuTTY"; -$configFile = "${softwareName}.reg"; -function New-TempDirectory() { - $tempDir = Join-Path $([System.IO.Path]::GetTempPath()) $([System.IO.Path]::GetRandomFileName()); - $null = New-Item -ItemType Directory $tempDir; - return $tempDir; -} +$null = New-Module { + $softwareName = "PuTTY"; + $configFile = "$($softwareName).reg"; -function Invoke-BackupPuTTY([Context] $context) { - $tempDir = New-TempDirectory; - $fileName = Join-Path "$tempDir" $configFile; - & reg export "HKCU\Software\SimonTatham" "$fileName" /y; - $context.Backup($tempDir, $context.SoftwareArchive($softwareName), @()); + function New-TempDirectory() { + $tempDir = Join-Path $([System.IO.Path]::GetTempPath()) $([System.IO.Path]::GetRandomFileName()); + $null = New-Item -ItemType Directory $tempDir; + return $tempDir; + } + + function Invoke-BackupPuTTY([Context] $context) { + $tempDir = New-TempDirectory; + $fileName = Join-Path "$tempDir" $configFile; + & reg export "HKCU\Software\SimonTatham" "$fileName" /y; + $context.Backup($tempDir, $context.SoftwareArchive($softwareName), @()); + } } diff --git a/scripts/Windows/Software/RetroArch/Manage.ps1 b/scripts/Windows/Software/RetroArch/Manage.ps1 index 2dd162fb..9fcd6b6e 100644 --- a/scripts/Windows/Software/RetroArch/Manage.ps1 +++ b/scripts/Windows/Software/RetroArch/Manage.ps1 @@ -1,7 +1,10 @@ . "$PSScriptRoot/../../Scripts/Context.ps1"; -$path = "C:/tools/RetroArch-Win64"; -$softwareName = "RetroArch"; -function Invoke-BackupRetroArch([Context] $context) { - $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"")); +$null = New-Module { + $path = "C:/tools/RetroArch-Win64"; + $softwareName = "RetroArch"; + + function Invoke-BackupRetroArch([Context] $context) { + $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"")); + } } diff --git a/scripts/Windows/Software/TrackMania Nations Forever/Manage.ps1 b/scripts/Windows/Software/TrackMania Nations Forever/Manage.ps1 index 1febaebd..8d5a4707 100644 --- a/scripts/Windows/Software/TrackMania Nations Forever/Manage.ps1 +++ b/scripts/Windows/Software/TrackMania Nations Forever/Manage.ps1 @@ -1,7 +1,10 @@ . "$PSScriptRoot/../../Scripts/Context.ps1"; -$path = "$HOME/Documents/TmForever"; -$softwareName = "TmNationsForever"; -function Invoke-BackupTmNations([Context] $context) { - $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"")); +$null = New-Module { + $path = "$HOME/Documents/TmForever"; + $softwareName = "TmNationsForever"; + + function Invoke-BackupTmNations([Context] $context) { + $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"")); + } } diff --git a/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 b/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 index 078d280c..0993c60f 100644 --- a/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 +++ b/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 @@ -1,7 +1,10 @@ . "$PSScriptRoot/../../Scripts/Context.ps1"; -$path = "$HOME/Documents/TrackMania"; -$softwareName = "TmUnitedForever"; -function Invoke-BackupTmUnited([Context] $context) { - $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"")); +$null = New-Module { + $path = "$HOME/Documents/TrackMania"; + $softwareName = "TmUnitedForever"; + + function Invoke-BackupTmUnited([Context] $context) { + $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"")); + } } diff --git a/scripts/Windows/Software/VisualStudio/Manage.ps1 b/scripts/Windows/Software/VisualStudio/Manage.ps1 index ff74edaf..33722b6a 100644 --- a/scripts/Windows/Software/VisualStudio/Manage.ps1 +++ b/scripts/Windows/Software/VisualStudio/Manage.ps1 @@ -1,27 +1,30 @@ Import-Module "KnownFolders"; . "$PSScriptRoot/../../Scripts/Context.ps1"; -$programs32Path = $(Get-KnownFolder "ProgramFilesX86").Path; -$vsInstaller = "$programs32Path/Microsoft Visual Studio/Installer/vs_installer.exe"; -[System.Tuple[string, string, string][]]$versions = @( - [System.Tuple]::Create("visualstudio2019enterprise", "VisualStudio.16.Release", "Microsoft.VisualStudio.Product.Enterprise")); +$null = New-Module { + $programs32Path = $(Get-KnownFolder "ProgramFilesX86").Path; + $vsInstaller = "$programs32Path/Microsoft Visual Studio/Installer/vs_installer.exe"; -function Get-ConfigPath([Context] $context, [string] $packageName) { - return Join-Path $($context.BackupRoot()) $packageName ".vsconfig"; -} + [System.Tuple[string, string, string][]]$versions = @( + [System.Tuple]::Create("visualstudio2019enterprise", "VisualStudio.16.Release", "Microsoft.VisualStudio.Product.Enterprise")); -function Invoke-BackupVisualStudio([Context] $context) { - foreach ($version in $versions) { - $configPath = Get-ConfigPath $context $version[0]; - $null = New-Item -Force -ItemType Directory "$(Split-Path -Parent $configPath)"; + function Get-ConfigPath([Context] $context, [string] $packageName) { + return Join-Path $($context.BackupRoot()) $packageName ".vsconfig"; + } - Start-Process -FilePath "$vsInstaller" ` - -Wait ` - -ArgumentList @( - "export", - "--channelId", "$($version[1])", - "--productId", "$($version[2])", - "--config", "$configPath", - "--quiet"); + function Invoke-BackupVisualStudio([Context] $context) { + foreach ($version in $versions) { + $configPath = Get-ConfigPath $context $version[0]; + $null = New-Item -Force -ItemType Directory "$(Split-Path -Parent $configPath)"; + + Start-Process -FilePath "$vsInstaller" ` + -Wait ` + -ArgumentList @( + "export", + "--channelId", "$($version[1])", + "--productId", "$($version[2])", + "--config", "$configPath", + "--quiet"); + } } } diff --git a/scripts/Windows/Software/git/Manage.ps1 b/scripts/Windows/Software/git/Manage.ps1 index 193a6679..a9ef195a 100644 --- a/scripts/Windows/Software/git/Manage.ps1 +++ b/scripts/Windows/Software/git/Manage.ps1 @@ -1,5 +1,8 @@ . "$PSScriptRoot/../../Scripts/Context.ps1"; -$configBaseName = ".gitconfig"; -$configPath = Join-Path "$HOME" "$configBaseName"; -function Invoke-BackupGit([Context] $context) {} +$null = New-Module { + $configBaseName = ".gitconfig"; + $configPath = Join-Path "$HOME" "$configBaseName"; + + function Invoke-BackupGit([Context] $context) {} +} \ No newline at end of file diff --git a/scripts/Windows/Software/osu!/Manage.ps1 b/scripts/Windows/Software/osu!/Manage.ps1 index f158db92..870a0cfe 100644 --- a/scripts/Windows/Software/osu!/Manage.ps1 +++ b/scripts/Windows/Software/osu!/Manage.ps1 @@ -1,10 +1,13 @@ . "$PSScriptRoot/../../Scripts/Context.ps1"; -$path = "$env:LOCALAPPDATA/osu!"; -$softwareName = "osu!"; -$genericConfigName = "osu!.User.cfg"; -function Invoke-BackupOsu([Context] $context) { - $archive = $context.SoftwareArchive($softwareName); - $context.Backup($path, $archive, @("-i@`"$PSScriptRoot/include.txt`"")); - & 7z rn "$archive" "osu!.$env:USERNAME.cfg" $genericConfigName; +$null = New-Module { + $path = "$env:LOCALAPPDATA/osu!"; + $softwareName = "osu!"; + $genericConfigName = "osu!.User.cfg"; + + function Invoke-BackupOsu([Context] $context) { + $archive = $context.SoftwareArchive($softwareName); + $context.Backup($path, $archive, @("-i@`"$PSScriptRoot/include.txt`"")); + & 7z rn "$archive" "osu!.$env:USERNAME.cfg" $genericConfigName; + } } diff --git a/scripts/Windows/Software/osu!lazer/Manage.ps1 b/scripts/Windows/Software/osu!lazer/Manage.ps1 index f02545d5..d8e9db7f 100644 --- a/scripts/Windows/Software/osu!lazer/Manage.ps1 +++ b/scripts/Windows/Software/osu!lazer/Manage.ps1 @@ -1,7 +1,10 @@ . "$PSScriptRoot/../../Scripts/Context.ps1"; -$path = "$env:APPDATA/osu"; -$softwareName = "osu!lazer"; -function Invoke-BackupOsuLazer([Context] $context) { - $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"", "-i!*.realm", "-i!*.db")); +$null = New-Module { + $path = "$env:APPDATA/osu"; + $softwareName = "osu!lazer"; + + function Invoke-BackupOsuLazer([Context] $context) { + $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"", "-i!*.realm", "-i!*.db")); + } } \ No newline at end of file diff --git a/scripts/Windows/Software/reWASD/Manage.ps1 b/scripts/Windows/Software/reWASD/Manage.ps1 index ae23cd06..8c95e99c 100644 --- a/scripts/Windows/Software/reWASD/Manage.ps1 +++ b/scripts/Windows/Software/reWASD/Manage.ps1 @@ -1,7 +1,10 @@ . "$PSScriptRoot/../../Scripts/Context.ps1"; -$path = "$env:PUBLIC/Documents/reWASD"; -$softwareName = "reWASD"; -function Invoke-BackupReWASD([Context] $context) { - $context.Backup($path, $context.SoftwareArchive($softwareName), @("-x@`"$PSScriptRoot/exclude.txt`"")); +$null = New-Module { + $path = "$env:PUBLIC/Documents/reWASD"; + $softwareName = "reWASD"; + + function Invoke-BackupReWASD([Context] $context) { + $context.Backup($path, $context.SoftwareArchive($softwareName), @("-x@`"$PSScriptRoot/exclude.txt`"")); + } }