1

I am trying to upgrade an application using an .msp file but every time I run the script I get a message saying the product I'm trying to upgrade from does not exist. My thought was there might be a bug in the original MSI so I decided to uninstall the application and a full install to the new version. When I run the script to Uninstall it works on some machines but not on others. When I try to uninstall using powershell it fails. When I use MSIEXEC /X I get the following message

"This action is only valid for products that are currently installed".

Next I decided to try and repair using MSIEXEC /fa and I get this: "This installation package cannot be opened. Verify that the package exists and that you can access it, or contat the application vendor to verify tat this is a valid Winds Installer package"

The strange thing is I can uninstall the application with no problems from Add\Remove programs with not issues and install the upgrade. The problem with this is that I have over 3000 users. From SCCM, I tried to supercede the old version to uninstall before installing the new version and that also failed. Any help you guys can provide would be helpful. The application is Taxprep Forms 2021.1.0 upgrading to 2021.2.0. i have added 2 of the scripts I tried.

For this script I tried doing a repair first then uninstall. I also tried using both product code and app name:

Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy Bypass

$uninstall32 = gci “HKLM:SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\” | foreach { gp $_.PSPath } | ? { $_ -match “Taxprep Forms 2021” } | select UninstallString
$uninstall64 = gci “HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\” | foreach { gp $_.PSPath } | ? { $_ -match “Taxprep Forms 2021” } | select UninstallString

if ($uninstall64) {
$uninstall64 = $uninstall64.UninstallString -Replace “msiexec.exe”,”” -Replace “/I”,”” -Replace “/X”,””
$uninstall64 = $uninstall64.Trim()
Write "Repairing Old install..."
Start-Process "msiexec.exe" -arg "/fa $uninstall64" -Wait
Write “Uninstalling…”
start-process “msiexec.exe” -arg “/X$uninstall64 /qb” -Wait}
if ($uninstall32) {
$uninstall32 = $uninstall32.UninstallString -Replace “msiexec.exe”,”” -Replace “/I”,”” -Replace “/X”,””
$uninstall32 = $uninstall32.Trim()
Write "Repairing Old install..."
Start-Process "msiexec.exe" -arg "/fa $uninstall32" -Wait
Write “Uninstalling…”
start-process “msiexec.exe” -arg “/X$uninstall32 /qb” -Wait}

I also tried:

Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy Bypass -Force 

$DisplayName = "Taxprep Forms 2021"
$TaxprepCheck = (Get-ItemProperty HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $DisplayName}) -ne $null
$PublicUser = "C:\Users\Public\CCH\Taxprep Forms 2021\"
$UnInstallCheck = "C:\Users\Public\CCH\Taxprep Forms 2021\Forms2021Uninstall.txt"
$Uninstalled = "C:\Logs\TaxprepForms2021.1.0Uninstalled.txt"
$TaxprepVer = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq $DisplayName}

If(-Not $TaxprepCheck) 
    {
        New-Item $Uninstalled -Force -ErrorAction Stop
        Set-Content $Uninstalled "Taxprep Forms 2021.1.0 is not installed"
        
    } 
else 
    {
        $TaxprepVer.Uninstall()
        New-Item $Uninstalled -Force -ErrorAction Stop
        Set-Content $Uninstalled "Taxprep Forms 2021.1.0 is successfully Uninstalled"
    }


If (Test-Path -Path $PublicUser)
    {
      New-Item $UnInstallCheck -Force -ErrorAction Stop
      Set-Content $UnInstallCheck "Taxprep Forms 2021.1.0 Uninstalled"
        
    }
Else
    {
      New-Item -ItemType "directory" -Path $PublicUser
      New-Item $UnInstallCheck -Force -ErrorAction Stop
      Set-Content $UnInstallCheck "Taxprep Forms 2021.1.0 Uninstalled"
        
    }

I have verified that the application is installed. It's in the registry. These scripts work on some computer and not on others. The machines it doesnt work on I have to uninstall the application through add\remove.

mcdurham
  • 11
  • 3
  • I have never heard that the uninstall of add/remove does anything else than call the command found under uninstallstring in the registry, but if one does work for you and the other does not I would advise to start manually on a machine where it does not work and then check the commandline via taskmanager (or maybe processexplorer/monitor to find the difference. (One thing I know is that the add/remove also shows programs installed per user and not machine. Could that be the case? – Syberdoor Feb 21 '22 at 09:28
  • Ok so it seemed I may have caused my own issue. When I initially deployed the application in SCCM, I set the User experience to “Install as User”. The switch I used when calling msiexec was All Users = 2. I switched the install to “Install for System and set All Users = “”. I would need to deploy the msi and do a full install rather than an upgrade using the msp. Installing as User may have messed up the registry setting for the initial install. Please advise if I’m on the right track here. Any help would be appreciated – mcdurham Feb 22 '22 at 02:44
  • I have not a lot experience with MSI installing per user, so not 100% sure but I think its plausible that this caused your problem. If this is the case it should however be possible to fix it with a bit of effort. You would have to deploy the uninstall per user again (check for the key in HKCU (no 64/32bit distinction there) uninstall key or if you can reasonably assume that all versions are the same just hard code it for once) and afterwards deploy a second program with per system installation for the new install. To guarantee the order you can use "run another program first" in prg options. – Syberdoor Feb 22 '22 at 07:36
  • That it works on some machines and not on others could mean that you would have to use two different methods for the two groups and thus first identify which is which (or just deploy both methods on all machines and let the "wrong one" fail silently (msi would do this for you if you use /qn instead of /qb no error message just does nothing)) – Syberdoor Feb 22 '22 at 07:40

1 Answers1

0

Ok so it seemed I may have caused my own issue. When I initially deployed the application in SCCM, I set the User experience to “Install as User”. The switch I used when calling msiexec was All Users = 2. I switched the install to “Install for System and set All Users = “”. I would need to deploy the msi and do a full install rather than an upgrade using the msp. Installing as User may have messed up the registry setting for the initial install.

mcdurham
  • 11
  • 3