(imported comment written by brolly3391)
Let’s rough out the logic.
if any of these applications are installed then uninstall them with the MSIExec.exe /X {PID} /QN command where we will retrieve the PID from the uninstall key of the registry.
tea version 1.0.0
tea version 1.0.0.0
tea expense reporting (any version)
travel expense accounting (any version)
note: since you are using contains, if the first line is true then so is the second line and the third line
So we want a fixlet that will uninstall all 4 different applications if any one of them is present. If it were my task, I would write 4 fixlets, one for each different application, but lets try and do it in one.
If you are on BES 6, just use the If Then flow control in action language to only run the wait actions that are applicable.
If you are on BES 5 then we need to get tricky with the substitution.
RELEVANCE:
exists key whose ((exists value “DisplayName” whose (it as string as lowercase contains “tea” ) of it AND exists value “DisplayVersion” whose (it as string contains “1.0.0” ) of it) OR (exists value “DisplayName” whose (it as string as lowercase contains “tea” ) of it AND exists value “DisplayVersion” whose (it as string contains “1.0.0.0” ) of it) OR (exists value “DisplayName” whose (it as string as lowercase contains “tea expense reporting” ) of it) OR (exists value “DisplayName” whose (it as string as lowercase contains “travel expense accounting” ) of it)) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry
a: true if any of the 4 applications are installed. Will be false and thus non-relevant once our action runs or if none of the applications are installed.
ACTION:
wait "MsiExec.exe /X " & {IF (exists key whose (exists value “DisplayName” whose (it as string as lowercase contains “tea”) of it AND exists value “DisplayVersion” whose (it as string contains “1.0.0”)of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry) THEN (name of key whose (exists value “DisplayName” whose (it as string as lowercase contains “tea”) of it AND exists value “DisplayVersion” whose (it as string contains “1.0.0”)of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry as string & “}”) ELSE “”} & /QN
wait "MsiExec.exe /X " & {IF (exists key whose (exists value “DisplayName” whose (it as string as lowercase contains “tea”) of it AND exists value “DisplayVersion” whose (it as string contains “1.0.0.0”)of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry) THEN (name of key whose (exists value “DisplayName” whose (it as string as lowercase contains “tea”) of it AND exists value “DisplayVersion” whose (it as string contains “1.0.0.0”)of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry as string & “}”) ELSE “”} & /QN
wait "MsiExec.exe /X " & {IF (exists key whose (exists value “DisplayName” whose (it as string as lowercase contains “tea expense reporting”) of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry) THEN (name of key whose (exists value “DisplayName” whose (it as string as lowercase contains “tea expense reporting”) of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry as string & “}”) ELSE “”} & /QN
wait "MsiExec.exe /X " & {IF (exists key whose (exists value “DisplayName” whose (it as string as lowercase contains “travel expense accounting”) of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry) THEN (name of key whose (exists value “DisplayName” whose (it as string as lowercase contains “travel expense accounting”) of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry as string & “}”) ELSE “”} & /QN
Notice the funky & “}” to double the final curly bracket on the PID if it exists. (page 10 in action guide)
Also notice that I took the MsiExec.exe /X and /QN parts out of the substitution and concatenated them instead.
When you run “MsiExec.exe /X NA /QN” on a command line, notice that the error that MSI would throw is suppressed by the /QN. But if you run “NA” at a command line it throws “Windows cannot find NA” error.
so simplified it looks like:
wait “MsiExec.exe /X “& { relevance here} &” /QN”
instead of
wait “{relevance here}”
If you do wait “MsiExec.exe /X NA /QN” then MSI exits quietly with a suppressed error and the actions continue.
If you do wait “NA” then the error is sensed up by the wait command and the actions fails.
If you already have the PIDs for the MSIs that you want to uninstall here is a slick alternative to the mess above:
RELEVANCE
(exists key “{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx1}” of it or exists key “{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx2}” of it or exists key “{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx3}” of it or exists key “{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx4}” of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry
ACTION:
wait “MsiExec.exe /X {”{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx1}}"} /QN"
wait “MsiExec.exe /X {”{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx2}}"} /QN"
wait “MsiExec.exe /X {”{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx3}}"} /QN"
wait “MsiExec.exe /X {”{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx4}}"} /QN"
Funky curly brackets again as per page 10 of action script guide…
Brolly