One task to uninstall and install

I am trying to make a single task using pre-install feature and getting failed notification with exit code 0 (which normally means success)

Snippet of my action are as follows

//**Begin Pre-install Marker = Uninstall 7zip

if {(exists keys “{{23170F69-40C1-2701-1806-000001000000}}” whose ( value “DisplayName” of it as string as lowercase contains “7-zip 18.06” ) of keys “HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall” of native registry)}
wait MsiExec.exe /x {{23170F69-40C1-2701-1806-000001000000} /qn
endif

//**End Pre-install Marker

// Log setup
parameter “mainSWDLogFolder” = "{parent folder of client folder of current site}/__Global/SWDDeployData"
folder create "{parameter “mainSWDLogFolder”}"
parameter “logFile” = “SWD_DeploymentResults.log”

// Install 7zip v 19.0.0.0
delete __createfile
parameter “logFolder” = “{parameter “mainSWDLogFolder”}”
// Run setup process
delete run.bat

// Use .bat to set working directory to packages root, for setup command.
action uses wow64 redirection {not x64 of operating system}
createfile until end
@ECHO OFF
cd "{parameter “baseFolder”}"
rem // See comments at the beginning of this action for an explanation of the comment markers.
echo %DATE% %TIME% >> "{parameter “logFolder”}{parameter “logFile”}"
echo Action ID: {id of active action} >> "{parameter “logFolder”}{parameter “logFile”}"
rem //**Begin Command Marker
echo Command: echo Command: msiexec.exe /i “7z1900-x64.msi” /qn >> "{parameter “logFolder”}{parameter “logFile”}"
set errorlevel=
msiexec.exe /i “7z1900-x64.msi” /qn >> “{parameter “logFolder”}{parameter “logFile”}” 2>&1
set SWDExitCode=%errorlevel%
rem //**End Command Marker

echo Return code: %SWDExitCode% >> "{parameter “logFolder”}{parameter “logFile”}"
echo. >> "{parameter “logFolder”}{parameter “logFile”}"
exit %SWDExitCode%
end

move __createfile run.bat
// You will not be able to stop or take action on an applicable BigFix Client until your installer completes.
// So ensure no user input is required.
// If your package absolutely must interact with the user, replace ‘override wait’ with ‘override run’ and ‘wait’ with ‘run’.
override wait
hidden=true
completion=job
wait run.bat

//**Begin Closing Marker
// Get the return code of the previous action.
parameter “returnCode” = “{exit code of action}”

// Task will now exit.
exit {parameter “returnCode”}
//**End Closing Marker

Despite the fixlet reporting back as failed, does it actually install 7-zip 19.0 like you want it to? In that case, I would guess it has to do with the success criteria. You could post the applicability relevance and we could take a look.

That said, this approach of uninstalling the old version and installing the new version in the same fixlet is not really necessary, unless there is some reason you don’t want to do an in-place upgrade.

If you write the relevance for the fixlet as follows, it will be applicable on computers without 7-Zip, or on computers that have 7-Zip at a version lower than 19,0. You won’t have to worry about uninstalling the old version, and you will have simpler success criteria.

not exists keys whose ( value "DisplayName" of it as string as lowercase contains "7-zip" AND value "DisplayVersion" of it as string >= "19.00" ) of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries ; x64 registries)

This asks: Is it true that there is no registry key with a display name of 7zip and a version greater than or equal to 19? It ensures that the fixlet will be relevant on computers without 7-zip, or with a lower version of 7-zip than 19.0.

1 Like

Hi sorry forgot to mention uninstalling 32bit version of 7zip and then install 64bit.

If try to upgrade to x64 7zip, it i installs fine but I end up with 2 versions , and if I then run uninstall targetting x86 using registry key msiexec.exe /x {guid} , i end up with corrupt application.

I see, thanks for clarifying. In that case, your approach here is fine, though you could also add an “Uninstall 32-bit” fixlet to a baseline with the “Install 64-bit” fixlet.

Either way, your original problem was about the fixlet reporting back failed. If you post the success criteria, we should be able to figure out what’s going on.

Hi @Toros72,

Specific to 7-zip, I have a script that will uninstall 7-zip using registry name.
Since you are uninstalling from 32 bit version then this might help you.
You can use below analysis to filter out 7-zip application on 32Bit systems.
exists (value "UninstallString" of keys whose((exists value "DisplayName" whose(it as string as lowercase contains "7-zip") of it)) of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries ))

And then you can use below Action script to uninstall it:
waithidden cmd.exe /c {("%22" & value "UninstallString" of it as string & "%22" & " /S" as string )of (keys whose((exists value "DisplayName" whose(it as string as lowercase contains "7-zip") of it)) of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of ( x32 registries ))}

As mentioned by @alinder, you can add install 7-zip 64 bit in a baseline and can use it.

1 Like

Yes if I use the baseline it works fine , the problem is I only want to install the 64bit version of 7zip to the machines that have the 32bit version and I my relevancy to install 64bit is essentially if "32 bit key exist in the registry . "

So if I uninstall the x86 first using baseline, then my relevancy for the 64bit goes out the door.

This is why I am am trying to run it as single task using the pre-install feature to check and if exist uninstall x86 , then proceed to install new 64bit version.

many thanks @alinder , I can indeed use a baseline to uninstall x86 version and then install x64 version of 7zip. Problem is I only want to target the upgrade to x64 using x86 registry that is if exist the uninstall and install new version. If I use baseline to uninstall x86 first ,then my relevancy will not work for install of x64 to specific machines which had it in the first case ( before uninstall) .