Basic MSI – A Simple Need (Part 2): Refresh the Desktop

(For background, please see Part 1 of this post)

Now that the Broadcom WIDCOMM Bluetooth Software desktop icon has been removed, we need a simple way of refreshing the desktop from within the MSI. 

The Post-Icon Removal MSI-Called Desktop Refresh

At first thought, it seemed that there must be VBScript out there that could accomplish this remedial task. 

Scouring the web turned up several suggestions, but none of them worked properly.  Some would work from a script being manually executed, but then would fail if executed through a custom action (WScript method access challenges, to name one).  Others simply didn’t work at all.  Trying to give focus to the desktop, and then using a “sendkey” function for a “F5″ refresh, wasn’t going to cut it this time either.  C code, found on the web, claimed it could accomplish what was needed; but not having much experience with writing and compiling C made it an unviable option.  The proposed solution would need to work regardless of what was open and running on the desktop during the installation.

After consulting with the Application Packaging Team at Coretek, a suggestion was proposed by Voltaire Toledo to use AutoIT to generate a script.  AutoIT “…is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.  It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys)” ( 

It was amazing how easy it was to create the script using AutoIT.  The best part was that it worked!  Here are the steps:

    1. Download and install AutoIt v3 from the site above.
    2. Create a folder in which to store AutoIT scripts.
    3. Right click in the folder.  Under “New”,  select “AutoIT v3 Script”.
    4. Rename the script to something more appropriate.
    5. Right-click the script and choose “Edit Script”.  The AutoIt SciTE script editor will open:

Script Editor

    1. Open an “Untitled”, empty, script window on first launch.  Enter the following line of code, with any additional comments, in the editor window:

ControlSend(‘Program Manager’, ”, ”, ‘{F5}’)

Hint – As seen above, “;” delimits a comment

  1. Save the script and close the script editor.
  2. Right-click on the recently-created script and choose “compile script”.  Choose either the 32-bit or 64-bit option (depending on the architecture of the system on which the executable will be run).
  3. The resulting executable file will appear in the script folder.

Now that an executable exists that can refresh the desktop, in any one of the aforementioned scenarios, it must be added to the basic MSI’s installation routine. 

This can be accomplished using a custom action from within InstallShield.  Here are the steps:

    1. Open the existing MSI or MST in InstallShield.
    2. Create a new custom action in InstallShield:

Custom InstallShield Action

  1. Choose to run an executable from the binary table.
  2. Click the “Browse” button to browse to the executable that was created from the AutoIt script earlier.
  3. Set the script to “immediate execution” and “always execute”.  Add any necessary install conditions to control when the custom action runs (at install, uninstall, maintenance mode, etc.).
  4. Ensure that the custom action is placed in the MSI’s execution sequence AFTER the changes to the desktop have been made (the registry key has been deleted as explained in Part 1), so that the desktop refresh shows the intended changes!

Viola!  Mission achieved!


2017-07-27T00:01:07+00:00 March 21st, 2012|Uncategorized|

About the Author: