Testing installers – running an MSI file

Launching MSI files is controlled by the msiexec program. When we launch MSI file, the msiexec.exe program is the one that's being launched for real, from the C:WindowsSystem32 folder.

This is why, as in the case of launching the other file types (taken up in the previous recipe), we can launch MSI files in two of the possible ways: launch the MSI file directly or pass it as a parameter to the msiexec program.

Getting ready

Place the Calculator Plus installer (the CalcPlus.msi file) to the root directory of C:\.

How to do it...

In order to run an MSI file we need to perform the following steps:

  1. Launch the following function:
    function testRunMSI()
    {
      var msi1 = "C:\CalcPlus.msi";
      var msi2 = "msiexec.exe /i C:\CalcPlus.msi";
      
      var ws = Sys.OleObject("WScript.Shell");
      ws.Run(msi1);
      ws.Run(msi2);
    }
  2. In the result, we will have two copies of the Calculator Plus installer launched.

How it works...

The inner workings are the same as in the previous recipe; however, the only peculiarity is that, in order to launch the MSI file as a parameter of the msiexec program, we will have to attach the parameter /i to it, in order to signify the path to the installer, to be passed further on.

There's more...

If the msiexec program were to be launched without parameters, it would display only the window with the list of usable options that are available. For example, the /quiet parameter allows launching silent mode installation, that is, without interacting with the user. This parameter is handy to use in case we need to install a new version of the tested application before running tests.

See also

  • Launching different applications and commands is discussed in detail in the Running external programs and DOS commands recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.36.38