Application / package can be uninstalled through command line using multiple methods. I will show you how to get the details first and then we have option to uninstall a single product or going with multiple products also possible.

Get the details of application using Command line

Lets first the the package details. Open command prompt with elevated rights. To see what programs are installed, run the command:

wmic product get name
wmic product get name

To filter out a specific program, use where clause with = sign for exact application name to specified.

Wmic product where name=’itunes’ get name
Wmic product where name=’itunes’ get name

Or we can also specify like clause but the query itself needs to be enclosed under double quotes (“”)

Wmic product where “name like ‘itunes’” get name
UninstallPackageCmdLine 03

The reason for using double quotes and like query is to enhance the power of this command line by adding more applications under it while at the same time usage of wildcard can be used which can be used as % sign.

wmic product where "name like 'itunes' or name like '7-Zip%'" get name
UninstallPackageCmdLine 04

Hence, we now have more than 1 application listed, and we can adopt the changes as we like.

Till now we were just focusing on the name of the application, but there are other details also for the application. Run the command:

wmic product where " name like '7-Zip%'" get /format:list

To get other details such as:
PackageCode
InstallDate
InstallSource
Language
LocalPackage
PackageCache
ProductID
Version
Vendor and others

UninstallPackageCmdLine 05

Key takeaways from all these commands is that we have Name & ProductCode which we can use for uninstallation. Let’s proceed with multiple ways we can use to do this.

Method 1 -Uninstall Application using Product Name

As shown previously, I used following command to list 2 programs with name column:

wmic product where "name like 'itunes' or name like '7-Zip%'" get name

I am going call the method uninstall to remove the product. Replace get name with call uninstall

wmic product where "name like 'itunes' or name like '7-Zip%'" call uninstall
UninstallPackageCmdLine 06

Uninstall method returned success

Executing (\\DESKTOP-PCD07V4\ROOT\CIMV2:Win32_Product.IdentifyingNumber="{EB0F77D3-CA79-432A-97C4-6C6BD98D3413}",Name="iTunes",Version="12.10.11.2")->Uninstall()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
     ReturnValue = 0;};
Executing (\\DESKTOP-PCD07V4\ROOT\CIMV2:Win32_Product.IdentifyingNumber="{23170F69-40C1-2702-2103-000001000000}",Name="7-Zip 21.03 (x64 edition)",Version="21.03.00.0")->Uninstall()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 0;
};

I could have used various other commands for single product such as:

wmic product where "name like '7-Zip%'" call uninstall
wmic product where "name like 'itunes' or name like '7-Zip%'" call uninstall
wmic product where name = ‘7-Zip 21.03 (x64 edition)‘ call uninstall


Method 2 – Uninstall application using Product Code

PackageCode is the Product Code / GUID of an application. Efficient way to get name and PackageCode together is to run:

wmic product where "name like 'itunes' or name like '7-Zip%'" get Name, PackageCode
UninstallPackageCmdLine 07

We can see such a neat and clean table view of product name and package code.

We have to run the commands separately for each GUID, you may also create a package / script to perform the same:

msiexec /x {86017D0B-2889-4DDD-AAA3-C9A6DE2A0D8E}
msiexec /x {23170F69-40C1-2702-2103-000002000000}

You will get Windows Installer message showing “Are you sure you want to uninstall this product?”

UninstallPackageCmdLine 08

To suppress the message, do a silent install, also lets try to suppress the restart behaviour (if application tries to do the same)

msiexec /x {86017D0B-2889-4DDD-AAA3-C9A6DE2A0D8E} /q /norestart

Getting Uninstall String from registry

There is one more way. In registry all application installation stores the information, one useful key is UninstallString

Navigate to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, you will be seeing lots of GUID’s and application names, select one by one to look for a specific application you are after, let’s say 7-Zip.

UninstallPackageCmdLine 09

I found the GUID, luckily the first one. UninstallString specified as MsiExec.exe /I{23170F69-40C1-2702-2103-000001000000}

/I is used for install, hence replace it with /x for uninstall string.


Discover more from SCCM | Intune | Device Management| Enterprise Mobility & Security

Subscribe to get the latest posts sent to your email.