diff --git a/functions/public/Invoke-WPFGetIso.ps1 b/functions/public/Invoke-WPFGetIso.ps1 index c40f9c41..1b448a4f 100644 --- a/functions/public/Invoke-WPFGetIso.ps1 +++ b/functions/public/Invoke-WPFGetIso.ps1 @@ -146,6 +146,19 @@ function Invoke-WPFGetIso { $sync.MicrowinScratchDirBox.Text = Join-Path $sync.MicrowinScratchDirBox.Text.Trim() '\' } + + # Detect if the folders already exist and remove them + if (($sync.MicrowinMountDir.Text -ne "") -and (Test-Path -Path $sync.MicrowinMountDir.Text)) + { + try { + Write-Host "Deleting temporary files from previous run. Please wait..." + Remove-Item -Path $sync.MicrowinMountDir.Text -Recurse -Force + Remove-Item -Path $sync.MicrowinScratchDir.Text -Recurse -Force + } + catch { + Write-Host "Could not delete temporary files. You need to delete those manually." + } + } Write-Host "Setting up mount dir and scratch dirs" $timestamp = Get-Date -Format "yyyyMMdd_HHmmss" diff --git a/winutil.ps1 b/winutil.ps1 index 9fd796f4..abe23f4d 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -10,7 +10,7 @@ Author : Chris Titus @christitustech Runspace Author: @DeveloperDurp GitHub : https://github.com/ChrisTitusTech - Version : 24.03.29 + Version : 24.03.30 #> param ( [switch]$Debug, @@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms # Variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "24.03.29" +$sync.version = "24.03.30" $sync.configs = @{} $sync.ProcessRunning = $false @@ -3303,6 +3303,19 @@ function Invoke-WPFGetIso { $sync.MicrowinScratchDirBox.Text = Join-Path $sync.MicrowinScratchDirBox.Text.Trim() '\' } + + # Detect if the folders already exist and remove them + if (($sync.MicrowinMountDir.Text -ne "") -and (Test-Path -Path $sync.MicrowinMountDir.Text)) + { + try { + Write-Host "Deleting temporary files from previous run. Please wait..." + Remove-Item -Path $sync.MicrowinMountDir.Text -Recurse -Force + Remove-Item -Path $sync.MicrowinScratchDir.Text -Recurse -Force + } + catch { + Write-Host "Could not delete temporary files. You need to delete those manually." + } + } Write-Host "Setting up mount dir and scratch dirs" $timestamp = Get-Date -Format "yyyyMMdd_HHmmss"