Uninstalling an MSI file using a WMI Query
Initial situation
In this Client Command, the WMI Query is used to determine the MSI IdentifyingNumber, which is then used in the Uninstall MSI package Command. By using the WMI Query, you can also work with wildcards to take into account several software versions. In this example, the software 7-Zip is to be uninstalled. The data compression program is often not on a uniform level in the company, which would make a tedious search for the individual product codes necessary. Avoid the individual uninstallations of different versions and thus ensure a uniform software level.
Otherwise, proceed as follows:
Select Script
- Navigate to the Client Commands > Create module.
- Click on Add in the ribbon bar. The Client Command Editor will open, where you need to decide whether it is a Console or Client Script. In this case, select the Cient Script.
Select and edit the WMI Request Command
- First select the WMI > WMI Query Command from the Command list.
- Double-click to open the Command. The launch window will show the details of the WMI settings.
- Select Simple mode.
- Select „root\cimv2“ from the drop down list under 'Root'.
- Click the WMI icon next to the WMI class. In the window that opens, locate 'Win32_Product' or enter it manually in the search box. Further down the right hand side you will see more information about each entry. Click OK.
- In the text box, type „CAPTION like "7-Zip%"“.
- Save the results to a variable. To do this, click the icon next to the variable name.
- In the window that opens, add a new variable under Actions. To do this, type 'WMIRESULT' in the variable name box and click the plus sign.

Inserting the WMIRESULT variable
9. Exit this step by clicking OK and return to the original window. Close this window by clicking OK again.

WMI Query
Select and edit the Uninstall MSI package Command
- Load the Uninstall MSI package (MSI) Command into the Script by selecting it with a double click. Indent the Command either via the quick selection bar or the shortcut CTRL + right arrow key so that it is displayed below the first Command (WMI Query).
- Enter the product code %WMIRESULT.IdentifyingNumber% in the Details tab for the product information. The variable is made up of the variable value that you previously saved (WMIRESULT) and the IdentifyingNumber. The IdentifyingNumber is the product ID that is needed to uninstall all software entries for 7-Zip.
- Select Unattended as the display mode.
- Under Options, tick the box next to Suppress Restart. If a restart is necessary for the uninstallation, it will not be carried out immediately afterwards. This means that other open programs or files will not simply be closed without you saving them.
- Click OK.

Uninstalling MSI packages
The last step is to save your Client Command in the editor.

Client Command Editor: Uninstalling an MSI file using a WMI query
On execution of the Client Command, the software 7-Zip is uninstalled from the Clients.