7-Zip
Update 7-zip the latest version and remove other version
Last updated
Update 7-zip the latest version and remove other version
Last updated
#Welcome to MisanZX Powershell Script
# Define the 7-Zip download URL for the latest version (64-bit version in this case)
$downloadUrl = "https://www.7-zip.org/a/7z2409-x64.exe" # replace url if new version
# Define the download and installation paths
$installerPath = "$env:TEMP\7z_installer.exe"
# Function to uninstall all versions of 7-Zip
function Uninstall-7Zip {
# Get all installed programs with "7-Zip" in their name
$installedPrograms = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "*7-Zip*" }
foreach ($program in $installedPrograms) {
Write-Host "Uninstalling: $($program.Name)"
$program.Uninstall() | Out-Null
}
}
# Uninstall all existing versions of 7-Zip
Uninstall-7Zip
# Download the latest 7-Zip installer
Write-Host "Downloading the latest 7-Zip installer..."
Invoke-WebRequest -Uri $downloadUrl -OutFile $installerPath
# Install the latest version of 7-Zip
Write-Host "Installing the latest version of 7-Zip..."
Start-Process -FilePath $installerPath -ArgumentList "/S" -Wait
# Clean up the installer
Remove-Item -Path $installerPath
Write-Host "7-Zip installation completed."