diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 index 12a64aa0..f496bffb 100644 --- a/scripts/Windows/Scripts/Context.ps1 +++ b/scripts/Windows/Scripts/Context.ps1 @@ -53,4 +53,10 @@ class Context { -Wait ` -NoNewWindow; } + + [string] GetTempDirectory() { + $tempDir = Join-Path $([System.IO.Path]::GetTempPath()) $([System.IO.Path]::GetRandomFileName()); + $null = New-Item -ItemType Directory $tempDir; + return $tempDir; + } } diff --git a/scripts/Windows/Software/PuTTY/Manage.ps1 b/scripts/Windows/Software/PuTTY/Manage.ps1 index 5d5d40bd..77a943e6 100644 --- a/scripts/Windows/Software/PuTTY/Manage.ps1 +++ b/scripts/Windows/Software/PuTTY/Manage.ps1 @@ -4,16 +4,11 @@ $null = New-Module { $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; - } - function Invoke-BackupPuTTY([Context] $context) { - $tempDir = New-TempDirectory; + $tempDir = $context.GetTempDirectory(); $fileName = Join-Path "$tempDir" $configFile; & reg export "HKCU\Software\SimonTatham" "$fileName" /y; $context.Backup($tempDir, $context.SoftwareArchive($softwareName), @()); + Remove-Item -Recurse $tempDir; } }