2024-11-19 16:59:53 -05:00
|
|
|
# Define URL and dynamically extract filename from URL
|
2024-11-19 15:01:34 -05:00
|
|
|
$url = "https://git.rimmyscorner.com/Rim/iw7-mod/releases/download/latest/iw7Installer.exe"
|
2024-11-19 16:59:53 -05:00
|
|
|
$file = Split-Path -Path $url -Leaf
|
2024-11-19 02:21:01 -05:00
|
|
|
|
2024-11-19 16:59:53 -05:00
|
|
|
# Check if file already exists and delete if necessary
|
|
|
|
if (Test-Path -Path $file) {
|
|
|
|
Write-Host "Removing existing file: $file"
|
|
|
|
Remove-Item -Path $file -Force
|
|
|
|
}
|
|
|
|
|
|
|
|
# Download the file using Invoke-WebRequest for better cross-platform compatibility
|
|
|
|
try {
|
|
|
|
Invoke-WebRequest -Uri $url -OutFile $file -ErrorAction Stop
|
|
|
|
} catch {
|
|
|
|
Write-Error "Download failed: $_"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Start the installer with arguments, wait for it to complete
|
|
|
|
try {
|
|
|
|
Start-Process -FilePath $file -ArgumentList "-s" -Wait
|
|
|
|
} catch {
|
|
|
|
Write-Error "Installation failed: $_"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Clean up downloaded file
|
|
|
|
Remove-Item -Path $file -Force
|