PDA

View Full Version : Automating an uninstallation via ARP.



Hamilton-Scott
03-14-2006, 04:41 PM
Attached screenshot shows two products. I basically fiddled the second product by generating a new product code GUID. Hence I can install it a second time.

I'm using AutoIT to create a switchboard where I can use a form and buttons to install and uninstall a product. So, one button needs to be able to automate the uninstallation of a product. In other words, instead of opening the ARP and then scrolling through the items, selecting one and clicking uninstall, I'd like to automate that functionally in a script.

In other words the equivalent of selecting the item to get the Change and Remove buttons and emulate the Remove. Maybe someone knows what goes on behind the scene when you click on Remove?

I was hoping the registry might offer a possible way to do this and I also notice that my Windows\Installer folder may also help me to identify the product but they are cryptic with their use of GUIDs and other arcane registry items. The motivation is to simplify the installation and uninstallation of several products. Putting the products on the machine is a breeze with AutoIT, but removing the buggers is something different.

Assuming I can do this, how do I run whatever ARP does to uninstall a product?

RobertDickau
03-14-2006, 04:47 PM
If you know the product code, it's msiexec /x {prod-uct-code}...

Hamilton-Scott
03-14-2006, 06:16 PM
Robert,

Thanks for the confirmation. I'd been working on the problem and got some valuable help from the AutoIT forum. Getting the product code is no great shakes as you suck it from the registry in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall folder. The only tricky bit is navigating through the product codes and comparing the DisplayName to the one I'm looking for. I mention that because I'll take the high road and assume the product code may change in the future but I don't think it will. Still, just to be sure...

Once identified in the registry, you can then get the UninstallString. I changed mine in the script to change msiexec /I to /X and appended the /nq option. I passed this through my script and it removed the product 100%.