66 lines
1.4 KiB
PowerShell
Raw Normal View History

2023-07-30 16:15:52 -04:00
param(
[string]$source,
[string]$destination
)
Clear-Host
2023-07-30 16:15:52 -04:00
Write-Host "Stopping installer ..."
$installer = Stop-Process -Name "SPTInstaller" -ErrorAction SilentlyContinue
2024-05-01 10:31:55 -04:00
if ($installer -ne $null)
{
2023-07-30 16:15:52 -04:00
Write-Host "Something went wrong, couldn't stop installer process'"
return;
}
2024-05-04 17:57:59 -04:00
if (-not(Test-Path $source) -and -not(Test-Path $destination)) {
Write-Warning "Can't find a required file"
Write-host ""
Write-Host "Press [enter] to close ..."
Read-Host
exit
}
2023-07-30 16:15:52 -04:00
Write-Host "Copying new installer ..."
2024-05-04 17:57:59 -04:00
$maxAttempts = 10
$copied = $false
2024-05-04 17:57:59 -04:00
while (-not $copied) {
2024-05-04 17:57:59 -04:00
$maxAttempts--
Write-Host "Please wait ..."
if ($maxAttempts -le 0) {
Write-Host "Couldn't copy new installer :( Please re-download the installer"
Write-Host ""
Write-Host "Press [enter] to close ..."
Read-Host
exit
}
Remove-Item $destination -ErrorAction SilentlyContinue
Copy-Item $source $destination
if (Test-Path $destination) {
$sLength = (Get-Item $source).Length
$dLength = (Get-Item $destination).Length
if ($sLength -eq $dLength) {
$copied = $true
break
}
sleep(2)
}
}
2023-07-30 16:15:52 -04:00
# remove the new installer from the cache folder after it is copied
Remove-Item -Path $source
2023-07-30 16:15:52 -04:00
Start-Process $destination
Write-Host "Done"