Forum Discussion

Oferv's avatar
Oferv
Super Contributor
13 years ago

TC's inconsistent behaviour


function RunMSI()

  {

  Log["AppendFolder"]("Start App installation")  

    var MSIpath = "C:\\Users\\<USER>\\App.msi";

     if(TestedApps.Find("msiexec.exe") == -1)

       {

         TestedApps.Add(msiexec.exe, "/i " + MSIpath);

       }

     TestedApps.msiexec.Run();        

  Log["PopLogFolder"]()   

  }



why the above function sometimes launch the msi and sometime it's not?

i can't relay on it to launch the msi this way.



thanks

6 Replies

  • Have you noticed if this happens when the program goes through your "if" statement, when it skips it or in both circumstances? This might help find the problem. 



    I use the "run()" function a lot and don't have any problems with it. You could try a delay between operations to see if maybe it hasn't completely added it to the tested apps before it tries to run it. 



    Hope this gives you some clues. 

    L-P

  • Hi Ofer,



    'msiexec.exe' is the Windows Installer service process. The service name is called 'msiserver'. This service starts when installation is invoked and stays running for 10 minutes after the installation is completed. This is made to prevent the loaded service data from being unloaded if the setups are run one after another. 



    To resolve the problem, insert the following code line:

          

    instead of this one:

          



    This will make TestComplete ignore the running 'msiexec.exe' process. More information can be found in the following article: TestedApp.Run.



    Besides that, you can use a 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.







  • Oferv's avatar
    Oferv
    Super Contributor
    Hi David,



    I figured out what causing the application i'm running to crash right after it's loading.

    i'm using TestedApps.msiexec.Run(-1, true); to run an msi file and i guess it can't work.

    i must use the following: http://support.microsoft.com/kb/891753/en-us

    but, when using the script written there:

    Const ALL_USERS = True
    Set objService = GetObject("winmgmts:")
    Set objSoftware = objService.Get("Win32_Product")
    errReturn = objSoftware.Install("<InstallerPackage.msi>", , ALL_USERS)

    it just doesn't work



    can you please edit this script so i can paste it to my script?



    thanks





  • Hi Ofer,



    Here is the JScript version of the code:



    var objService = GetObject("winmgmts:");

    var objSoftware = objService.Get("Win32_Product");

    var errReturn = objSoftware.Install("<InstallerPackage.msi>", "", true);

    if (errReturn == 0)

      Log.Message("Installation completed");

    else 

      Log.Message("Installation failed"); 





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



    var WshShell = new ActiveXObject("WScript.Shell");  //Creates the WScript.Shell object

    WshShell.Run("msiexec.exe /i" + "<InstallerPackage.msi>");  //Installs the msi package via the command line

  • Oferv's avatar
    Oferv
    Super Contributor
    Hi David,



    First of all thanks,



    I understand that the first piece of code is a silent installation and the second one just run the msi while loading the GUI.just wanted know if i got it right.



    that's great!!!



    it's working great