Unable to add parameters to uninstall string

Hi all,

I have some issues adding paramters such as /qn and /norestart to an uninstall string found in the registry.

The query I’m using is:
(value "UninstallString" of key whose(value "DisplayName" of it as string as lowercase contains "<product name>") of keys whose(exists keys of it) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" of native registry)

Which returns the following output:
Current Selection Evaluates To:

MsiExec.exe /X{B0039443-C643-44FC-9B05-844F59D66900}%00


Evaluation time: 54.662 ms

When I attempt to use the query in question in the action script, I can’t seem to add “/qn /norestart” to this string.
My actionscript line looks like this
wait {value "UninstallString" of key whose(value "DisplayName" of it as string as lowercase contains "<product name>") of keys whose(exists keys of it) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" of native registry} & "/qn /norestart"

By inspecting the Client Log of the Fixlet Debugger, it becomes eminent that /qn /norestart is not added to the string:

STATUS: Running action...

Command started - wait MsiExec.exe /X{AD46876B-6C19-4BA0-9739-9463DE6EE389}

Command succeeded (Exit Code=1602) wait MsiExec.exe /X{AD46876B-6C19-4BA0-9739-9463DE6EE389}

My guess is that this is due to the null byte in the end of the uninstall string?

How can one add the paramters in question to this uninstall string? Any help i much appreciated! :slight_smile:

Best regards,

Since you are closing the relevance substitutionyou don’t need the ampersand or quotes. Try

wait {value "UninstallString" of key whose(value "DisplayName" of it as string as lowercase contains "<product name>") of keys whose(exists keys of it) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\E-1-5-18\Products\" of native registry} /qn /norestart

Hi,

Unfortunately it does seem to produce the same result:

STATUS: Running action...
Command started - wait MsiExec.exe /X{AD46876B-6C19-4BA0-9739-9463DE6EE389}
Command succeeded (Exit Code=1602) wait MsiExec.exe /X{AD46876B-6C19-4BA0-9739-9463DE6EE389}

--- Result ---
Evaluation completed successfully!

Best regards,

I’ve had better success calling msiexec directly and just using relevance to pull the GUID. I also tend to parameterize my uninstalls so it makes it easier to copy paste, because so many programs we have to remove use different uninstalls…

This allows you to use commands like this for MSI based installers:

parameter “DisplayName”=“product name”
parameter “Publisher”=“publisher name”

//32-bit removal using msiexec.exe
if{exists keys whose ((value “DisplayName” of it as string as lowercase contains (parameter “DisplayName”) as lowercase) AND (value “Publisher” of it as string as lowercase contains (parameter “Publisher”) as lowercase) AND (value “uninstallstring” of it as string as lowercase contains “msiexec.exe”)) of keys “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry}
waithidden msiexec.exe /X {name of key whose ((value “DisplayName” of it as string as lowercase contains (parameter “DisplayName”) as lowercase) and (value “Publisher” of it as string as lowercase contains (parameter “Publisher”) as lowercase) and (value “uninstallstring” of it as string as lowercase contains “msiexec.exe”)) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry} /qn
endif

//64-bit removal using msiexec.exe
if{exists keys whose ((value “DisplayName” of it as string as lowercase contains (parameter “DisplayName”) as lowercase) AND (value “Publisher” of it as string as lowercase contains (parameter “Publisher”) as lowercase) AND (value “uninstallstring” of it as string as lowercase contains “msiexec.exe”)) of keys “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry}
waithidden msiexec.exe /X {name of key whose ((value “DisplayName” of it as string as lowercase contains (parameter “DisplayName”) as lowercase) and (value “Publisher” of it as string as lowercase contains (parameter “Publisher”) as lowercase) and (value “uninstallstring” of it as string as lowercase contains “msiexec.exe”)) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry} /qn
endif

Bottom line, if you just want the line I use for (32-bit) removal:

waithidden msiexec.exe /X {name of key whose ((value “DisplayName” of it as string as lowercase contains “DisplayName” as lowercase) and (value “Publisher” of it as string as lowercase contains “Publisher” as lowercase) and (value “uninstallstring” of it as string as lowercase contains “msiexec.exe”)) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry} /qn

Hi and thanks for your suggestion.

However, this particular software is not found under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, and the GUID (as far as I can see) is only visible in the UninstallString at the location I use for my query.

Since I fear that the trailing null byte is what is causing this issues, I have attempted to extract the GUID using regex in the following manner:

waithidden msiexec.exe /X {parenthesized parts 1 of first matches (regex "(\{.*\})") of (it as string) of value "UninstallString" of key whose(value "DisplayName" of it as string as lowercase contains "<product>") of keys whose(exists keys of it) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" of native registry} /qn /norestart

However, when I run this in the fixlet debugger, it fails with the following error:

STATUS: Running action...
Command failed (Relevance substitution failed)

Error message from console: Relevance clauses must be surrounded by { and } guards.

Are there any obvious errors in my query?

Best regards,

Now that you’ve switched to using a regular expression, and the expression contains the “}” character, you need to escape that by doubling it to “}}”. Otherwise the actionscript interpreter sees this as the end of the relevance substitution.

Try
waithidden msiexec.exe /X {parenthesized parts 1 of first matches (regex "(\{.*\}})") of (it as string) of value "UninstallString" of key whose(value "DisplayName" of it as string as lowercase contains "<product>") of keys whose(exists keys of it) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" of native registry} /qn /norestart

2 Likes

Thanks alot JasonWalker,

Now it is working like a charm! Thanks again.

Best regards,

Another way you could have done this it to take your original relevance and do a preceding text of last “}” on the value and add a “}” to the end of the result. I had to do this a few weeks ago for the same issue.