2

I am looking for a script or some cmd command to uninstall any app from my computer. I am using Windows OS. Being an automation analyst I have to constantly run automated tests for different products whenever there is new build. So every time I have to uninstall and install build which takes time.

I did try the following command:

wmic product where name="product name" call uninstall

Apparently it did work, but it didn't remove the app from control panel and also when I tried to install again it shows installation menu saying uninstall is needed. However the app's data is removed from installation directory.

Stein Åsmul
  • 34,628
  • 23
  • 78
  • 140
Noman Ajmal
  • 21
  • 1
  • 4

2 Answers2

1

No Silver Bullet

There is no silver bullet when it comes to automating installation or uninstallation - but there is a quick trick that is described in the "General Uninstall" section.

There are heaps of different flavors of installer types - and the list keeps growing. Automating them is a bit of a black art as you will be fully aware of. Not rocket science, but tedious and tiresome when things don't work reliably and there is no suitable remedy that consistently works all the time.

I have written about these issues many times before and cross-linked the content very heavily. It is messy, but if you follow the links and web of linked pages below you should be able to find the information you need for many different setup.exe and installer types.

General Uninstall

Before going into the below ad-hoc list of different types of installers / uninstallers and how to handle their command line parameters. I want to add that you can find a list of most of the products installed on the system in these registry locations:

  • HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall (64-bit)
  • HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall (32-bit)
  • HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall (per-user)

By checking for UninstallString or equivalent for a specific entry under these parent keys, you can get a general idea of how to uninstall the product in question by command line.

Try this simple approach first, but do read the material below for a better understanding of how installers of various kinds operate. Not all deployment tools and deployment operations register properly in these locations.

Apps are not found in these locations in the registry, only MSI installers (Windows Installer) and some - or most - of legacy setup.exe installers.


Installer Types & Uninstall (and extract for setup.exe)

  1. "Unattended.com": The easiest and quickest read on the topic of automating install / uninstall could be this one: http://unattended.sourceforge.net/installers.php
    • This is aging content, but I remember it as helpful for me back in the day.
    • And crucially it is not my own content - so I don't link entirely to myself! :-) (most of the links below are earlier answers of mine). Apologizes for that - it is just easier to remember your own content - you know it exists - and it is easier to find.
  2. MSI: The most standardized packages to deal with are MSI packages (Windows Installer).
  3. Setup.exe: Installers in setup.exe format can be just about anything, including wrapped MSI files (Windows Installer). For MSI files wrapped in setup.exe files you can use the previous bullet point's standard mechanisms to uninstall (they are registered by product code GUID). Below are some links on how to extract the content of setup.exe files for various types of setup.exe files and also links to pages documenting the actual setup.exe command line parameters:
  4. Other Tools: There are many tools that can be used to create installers / setup.exe files. Here are some of the bigger ones (just FYI - no command line switches to find here, just product information):
  5. Apps: And there is the whole new world of apps.

Other Links:

Stein Åsmul
  • 34,628
  • 23
  • 78
  • 140
0

I figured it out myself and it works for many projects which have .exe setups. Following is the format 1. Open terminal with admin rights 2. go to path in where setup that you used to install the product. 3. Once there then type: setupname.exe /uninstall /q

Noman Ajmal
  • 21
  • 1
  • 4