delete temp directory if already exists

This commit is contained in:
2022-11-10 19:29:55 -05:00
parent c0eee62f1e
commit a6d1172bfd
+7
View File
@@ -6,6 +6,13 @@ LogMsg "Creating: ${TEMPDIR}"
Try { New-Item -Path $TEMPDIR -ItemType Directory -Force -ErrorAction Stop }
Catch { LogErr $_.Exception.Message ; Exit }
# Recursively delete $TEMPDIR if it already exists
If ( Test-Path $TEMPDIR ) {
LogMsg """${TEMPDIR}"" already exists and will be deleted"
Try { Remove-Item -Path $TEMPDIR -Recurse -Force }
Catch { LogErr $_.Exception.Message }
}
# Write $CONFIG to install_config.ini
Try { $CONFIG | Out-File -FilePath "${TEMPDIR}\install_config.ini" -Force -ErrorAction Stop }
Catch { LogMsg "Cannot write configuration file! This script will exit." ; LogErr $_.Exception.Message ; Exit }