How to get log while running MSI by using WMI? RRS feed

  • Question

  • Hi all,

    There is a program to run MSI by using WMI. It works but there is no log. How should I get log by changing "Options" value? the source code is:

    ConnectionOptions connOptions = new ConnectionOptions();
                connOptions.Impersonation = ImpersonationLevel.Impersonate;
                connOptions.EnablePrivileges = true;
                ManagementScope manScope = new ManagementScope
                            (String.Format(@"\\{0}\ROOT\CIMV2", address), connOptions);
                ObjectGetOptions objectGetOptions = new ObjectGetOptions();
                string retVal = "0";
                    ManagementPath managementPath = new ManagementPath("Win32_Product");
                    ManagementClass processClass = new ManagementClass
                            (manScope, managementPath, objectGetOptions);
                    ManagementBaseObject inParams = processClass.GetMethodParameters("Install");
                    inParams["AllUsers"] = true; //to install for all users    
                    inParams["Options"] = "REBOOT=ReallySuppress INSTALLDIR=\"" + targetfolder  "\"";
                    inParams["PackageLocation"] = msipath; //source file must be on the remote machine
                    ManagementBaseObject outParams = processClass.InvokeMethod("Install", inParams, null);
                    retVal = outParams["ReturnValue"].ToString();


    Monday, May 12, 2014 8:03 AM

All replies

  • Check the command line options manually: msiexec /?. So try prepending an option like this: @"/L ""C:\MyLogFile.txt""".

    • Edited by Viorel_MVP Monday, May 12, 2014 11:37 AM
    Monday, May 12, 2014 11:33 AM
  • Thanks, it's not correct to use "C:\log.txt", it should be "'property=setting'", but I don't know property name. I tried "MSILOGGING=*", "MSILOGLOCATION=C:\Log.txt" and "LOG=C:\Log.txt", but failed.
    Monday, May 12, 2014 2:03 PM
  • The Install method is:


    but I don't know how to set Options.

    • Edited by VicZhang Monday, May 12, 2014 2:18 PM
    Monday, May 12, 2014 2:16 PM