Forum Discussion

itvrdeich's avatar
itvrdeich
Contributor
13 years ago

Run MSI from within a C# Script.

Hi Everyone, 

Need some urgent help. I need a way of running a msi via command line in my script. 

Is there anyway I can just pass the command line the path to my msi and run it? 

I dont know how to use command line in scripts.

Examples please. 

Thanks.

5 Replies


  • Hi Ivan,



    You can use the code below to run your msi file via the command line in your script:

    Sub InstallMSIviaCommandLine()

      Set WshShell = CreateObject("WScript.Shell") //Creates the WScript.Shell object

      WshShell.Run "msiexec.exe /i <YourInstallerPackage.msi>" //Installs the msi package via the command line

    End Sub




    For more information, please refer to the About Windows Installer - Command Line Options MSDN article.



    Besides that, you can use the WMI script to install your msi file. To learn how to do this, please see the How to install a Windows Installer package from a Windows Management Instrumentation (WMI) script article.



    I hope this helps.







  • Hi David.



    I now have another problem regarding msiexec.exe process and the object not found error.

    I have multiple msiexec.exe processes running under different usernames (local admin and SYSTEM).

    Test Complete is getting confused and cant find any object because my mapping  look for msiexec with a default process index of 1 (msiexec, 1) but the installer is actually running under the different username which holds a different index (msiexec, 2).

    How do i fix my mapping to deal with multiple processes of the same name, but different indexes.

    The screenshot shows two processes called msiexec running and the failure message in TC.
  • Hi David.



    I know have another problem regarding msiexec.exe process and the object not found error.

    I have multiple msiexec.exe processes running under different usernames (local admin and SYSTEM).

    Test Complete is getting confused and cant find any object because my mapping  look for msiexec with a default process index of 1 (msiexec, 1) but the installer is actually running under the different username which holds a different index (msiexec, 2).

    How do i fix my mapping to deal with multiple processes of the same name, but different indexes.

    The screenshot shows two processes called msiexec running and the failure message in TC.

  • Hi Ivan,



    Here is what you need to do:

    1. Create a Name Mapping scheme for your test (you can simply record a test - the scheme will be created automatically).

    2. Edit the mapping scheme for the process object:

      - if the Index property is present in the scheme, remove the property so that the process is recognized only via its ProcessName property;

      - switch to the Required Children tab (see the bottom part of the name mapping editor);

      - check the box corresponding to the installer main window to make it the required child of the process object. This will make TestComplete always use the process which contains the window you need, regardless of the index of the process.



    See the 'Specifying Child Objects Required for Mapped Object Identification' help article for more information.



    If this does not help, please submit a request to us. Zip your entire project suite folder along with the log of the failed test execution and attach it to the request.