How to automate changing the VMware Tools installation in Windows


A while ago I blogged about the VMware Tools for Windows MSI package, what hidden components it includes, and how you can take complete control over the installation or upgrade process by using appropriate msiexec command lines.

The following question was raised in this context: How do you modify an existing installation of VMware Tools (i.e. add or remove components) without re-installing or updating to a new version?

Since vSphere 5.5 you have - by default - the Change and Repair options available for the VMware Tools package in the Programs and Features control panel (Run: appwiz.cpl). This will launch the MSI installation wizard and lets you add or remove components of the package, but - just like at the initial installation - it will not expose all the available components.

The complete list of components is in the post mentioned above. There you will also find a vbs-script (WiListPrd.vbs) mentioned that you can use to list what components of the package are installed.


Remove an installed component

You can use "msiexec /i" to remove one or more components of the package. If you want to silently remove e.g. the Unity and TrayIcon components then use the command

   msiexec /i {PackageCode} Remove=TrayIcon,Unity /qn

PackageCode needs to be replaced with the actual package code of the VMware Tools. This will be different with every version - for the VMware Tools of ESXi 5.5 U1 it is e.g. {791E3113-0F3A-4541-8CE7-AE386B2FF8AD}. The WiListPrd.vbs script will output the correct package code for you. If you want to find it out with your own vbs-script then use something like the following code:
Set installer = Wscript.CreateObject("WindowsInstaller.Installer")
For Each productCode In installer.Products
   If installer.ProductInfo(productCode, "ProductName") = "VMware Tools" Then Exit For
Next
Wscript.Echo "productCode=" & productCode

Install a missing component

To install a missing component you might try to use a very similar msiexec command by just replacing the Remove= option with AddLocal=, but in many cases this will fail. Why? Because the command needs to access the original MSI installation source, and that might no longer be locally cached.

A safe way to install missing components is to use the setup.exe (resp. setup64.exe) command from the original VMware Tools installation ISO (Note: Its version must exactly match the version that is already installed!). This example will silently add the VShield component:

   setup[64].exe /s /v AddLocal=VShield /qn


Using WMI for MSI queries

Using a vbs-script on modern Windows versions might appear very outdated. The new de-facto scripting standard for Windows is PowerShell for sure. So I looked for a PowerShell script to determine the package code of the VMware Tools and I quickly found some examples that make use of WMI.

However, MSI queries through WMI take very long and expose some weird behavior (that was also confirmed by others). If you run e.g.

   wmic product where Description="VMware Tools" get IdentifyingNumber

it will return the correct result after a while, but in the Application event log you will see that Windows has reconfigured(?!) every installed MSI package on the system while executing the query:


In contrast the vbs-script that uses the COM object WindowsInstaller.Installer executes very fast and does not show this behavior. So I stuck with it.

Of course you can also use the COM object with PowerShell, but this is not so straight-forward as it is with VBScript. I'll leave it up to you to find out more ...


This post first appeared on the VMware Front Experience Blog and was written by Andreas Peetz. Follow him on Twitter to keep up to date with what he posts.



No comments:

Post a Comment

***** All comments will be moderated! *****
- Please post only comments or questions that are related to this post's contents!
- Advertising and link spamming will not be tolerated!