I would create a script and remove all the previous versions before installing the latest. You can query the msi codes of each version and use the uninstall strings or use wmic to nuke all the versions in one go.
Need to replace old versions of 7-zip with the latest
I created a Device Collection which populates with all machines running a version of 7-zip previous to v24.09 - total of 321 machines.
Next, I built an application to install v24.09 and supersede v22, which was available for install in Software Center.
This mostly worked as expected. The remaining problem is there were 23 versions, across the 321 machines, going back to v9. Now, I have 306 machines that have two versions installed - v24 and whichever old version was there when they were put into the Collection.
I'm not sure what would be the best way to get to the goal of all machines using 7z only run v24.09.
Suggestions are appreciated.
4 answers
Sort by: Most helpful
-
Rahul Jindal [MVP] 10,776 Reputation points MVP
2025-02-18T21:29:53.4033333+00:00 -
AllenLiu-MSFT 47,971 Reputation points Microsoft Vendor
2025-02-19T06:23:00.89+00:00 Hi, @Kkoop
Thank you for posting in Microsoft Q&A forum.
Like Rahul said, you can create a script that will uninstall all versions of 7-Zip except for v24.09. You can use PowerShell or a similar scripting language to identify and remove the older versions. Deploy this script to the collection of machines that have old versions.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Add comment".
-
KKoop 10 Reputation points
2025-02-19T13:52:43.6433333+00:00 Thanks to both of you for your suggestion. Deploying a script that removes all earlier-than-24 versions of 7z sounds like a good solution.
Would you have a reference I could use to create the script? I'm medium-level with Powershell, so not intimidated by the prospect, just don't know how I would go about identifying and then uninstalling.
Thanks!
-
AllenLiu-MSFT 47,971 Reputation points Microsoft Vendor
2025-02-20T06:41:41.71+00:00 Hi, @KKoop
You may check this for a reference:
# Define the minimum version to keep $minimumVersion = [Version]"24.09" # Get the list of installed 7-Zip versions $installedVersions = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | Get-ItemProperty | Where-Object { $_.DisplayName -like "7-Zip*" } | Select-Object DisplayName, DisplayVersion, UninstallString # Loop through each installed version foreach ($version in $installedVersions) { $currentVersion = [Version]$version.DisplayVersion if ($currentVersion -lt $minimumVersion) { Write-Output "Removing 7-Zip version $($version.DisplayVersion)" & $version.UninstallString /S } else { Write-Output "Keeping 7-Zip version $($version.DisplayVersion)" } }