The Scenario: App installs but may update itself or generate a random key every time (idiots).
The Solve: If the below script comes out correctly formatted, it has the logic to detect the uninstall strings and piece together the uninstall. Keep in mind the app is 32-bit and I didn’t want to spend more time than I had to.
I’ve seen other people on here post similar scripts to uninstall software. Out of curiosity, why not use the get-installedapplication function to get the uninstall string? That way you let the function figure out if it’s 64-bit or not…
Simple, that function only gets certain values:
UninstallSubkey
ProductCode
DisplayName
DisplayVersion
UninstallString
InstallSource
InstallLocation
InstallDate
Publisher
Is64BitApplication
The function would be best served by allowing input to include (partial) display name, specific reg value (quietuninstallstring here). This method also generated the Uninstall command for me so that I didn’t need to know switches. I put this into a function which I used in both preinstall and uninstall state. Also expanded it a little more to include logging…it’s much more effective now.
The get-installedapplication does support partial display names. It supports name, exact and even wildcard. You could submit a feature request to have QuietUninstall added to the list of values it finds or even just add it yourself- QuietUninstallString = $regKeyApp.QuietUninstallString. I think I’m going to do that. Thanks for the idea. My way above got the default uninstall parameters, I just manually added the /quiet /norestart since I wasn’t pulling the QuietUninstall key and didn’t have all the parameters. But it did have the /uninstall. So it looks like both of our methods get the job done, just in different ways.