Last modified by Sabrina V. on 2025/03/04 07:13

Show last authors
1 {{aagon.floatingbox/}}
2
3 = Initial situation =
4
5 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.
6
7 {{aagon.infobox}}
8 This is only one way of uninstalling an MSI file using a Client Command. If, for example, you only want to install one version of a software, you can also do this using the product code and //ignoring errors// (using error codes). You can find out how to do this [[here>>doc:ACMP.67.ACMP-Solutions.Client Commands.Use Cases für Client Commands.Deinstallation einer MSI-Datei.WebHome]].
9 {{/aagon.infobox}}
10
11 Otherwise, proceed as follows:
12
13 == Select Script ==
14
15 1. Navigate to the //Client Commands// > //Create// module.
16 1. 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.
17
18 == **Select and edit the WMI Request Command** ==
19
20 {{aagon.warnungsbox}}
21 Within the WMI query you will access the Win32_Product WMI class. This class represents the products as they are installed by Windows Installer or as they are stored as installation packages on clients. This can result in a large number of entries in the event log as all MSI installation files are listed. Please be aware that this step can cause delays. [[Microsoft>>https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa394378(v=vs.85)]] describes this issue as follows:
22
23 //Win32_Product is not query optimized. Queries such as "select * from Win32_Product where (name like 'Sniffer%')" require WMI to use the MSI provider to enumerate all of the installed products and then parse the full list sequentially to handle the “where” clause. This process also initiates a consistency check of packages installed, verifying and repairing the install. With an account with only user privileges, as the user account may not have access to quite a few locations, may cause delay in application launch and an event 11708 stating an installation failure.//
24 {{/aagon.warnungsbox}}
25
26 1. First select the //WMI// > //WMI// //Query// Command from the Command list.
27 1. Double-click to open the Command. The launch window will show the details of the WMI settings.
28 1. Select Simple mode.
29 1. Select „root\cimv2“ from the drop down list under 'Root'.
30 1. 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//.
31 1. In the text box, type „CAPTION like "7-Zip%"“.
32 1. Save the results to a variable. To do this, click the icon next to the variable name.
33 1. 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.
34
35 [[Inserting the WMIRESULT variable>>image:1736511066054-639.png||data-xwiki-image-style-alignment="center"]]
36
37 9. Exit this step by clicking OK and return to the original window. Close this window by clicking //OK// again.
38
39 [[WMI Query>>image:65_Use Case Client Commands_WMI Abfrage_Details_539.png]]
40
41 == **Select and edit the //Uninstall MSI package //Command** ==
42
43 1. 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).{{aagon.infobox}}If you have multiple installations of the same software in your environment (in this example, 7-Zip), you can also use the indentation to find multiple items. The Command is executed multiple times because it is a loop Command and the software you are looking for is uninstalled until no more matching IDs are found.{{/aagon.infobox}}
44 1. 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.
45 1. Select //Unattended //as the display mode.
46 1. 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.
47 1. Click //OK//.
48
49 [[Uninstalling MSI packages>>image:65_Use Case Client Commands_MSI Paket deinstallieren_WMI Result_504.png]]
50
51 The last step is to save your Client Command in the editor.
52
53 [[Client Command Editor: Uninstalling an MSI file using a WMI query>>image:65_Use Case Client Commands_WMI Abfrage Gesamtübersicht_1436.png]]
54
55 On execution of the Client Command, the software 7-Zip is uninstalled from the Clients.
© Aagon GmbH 2025
Besuchen Sie unsere neue Aagon-Community