The main task of this short part is get some computer name and install on this PC needed software (throught msiexec.exe)

I do this

    {                       

            Credential creds = new Credential();
            UserAttr UserCredential = new UserAttr();
            UserCredential = creds.DefaultFlagsTest();              
            ConnectionOptions connection = new ConnectionOptions();
            connection.Username = UserCredential.UserName;
            connection.Password = UserCredential.password;
            connection.Authentication = AuthenticationLevel.PacketPrivacy; 
            connection.Authority = "ntlmdomain:tcc1";

            ManagementScope scope = new ManagementScope(
                "\\\\"+computerName+"\\root\\CIMV2", connection);
            scope.Connect();

            ManagementClass classInstance =
                new ManagementClass(scope,
                new ManagementPath("Win32_Process"), null);

            ManagementBaseObject inParams = classInstance.GetMethodParameters("Create");

            inParams["CommandLine"] = @"msiexec.exe /qb /m log.mif /i ""\\tcc1-pgh10.tcc1.local\swshare$\Packages\NetAgent_10.0.3361\exec\Kaspersky Network Agent.msi""";       

            ManagementBaseObject outParams = classInstance.InvokeMethod("Create", inParams, null);

            int res = int.Parse(outParams["ReturnValue"].ToString());

            if (res == 0)
            {
                MessageBox.Show(outParams["ReturnValue"].ToString(), "Result");                   
            }
            else throw new System.ComponentModel.Win32Exception(res);             

            Close();           
    }

the program returns 0, but its doesnt mean that msiexec is complete with the same success. Error is check path of package .. or smth. But what i see in a log file log.mif:

..............................
START ATTRIBUTE
NAME = "Product"
ID = 2
ACCESS = READ-ONLY
STORAGE = SPECIFIC
TYPE = STRING(64)
VALUE = "\tcc1-pgh10.tcc1.local\swshare$\Packages\NetAgent_10.0.3361\exe"
END ATTRIBUTE
..............................

he crops the name of package at 64 symb. The reason is that parametr CommandLine of Win32_Process.Create has this limit. I don't know how to overcome this...

Win32_Process.Create also has property CurrentDirectory, thath seems can solve this propblem. But he can't process UNC paths.

and i can't do the install directory shorter. it is not right. (And i can say that i've done this. And its worked)

Please, maybe you know how to solve this propblem with a long installation path? different properties as TARGETDIR or INSTALLDIR set only path TO install, no FROM...

有帮助吗?

解决方案

I gave up

START ATTRIBUTE 
NAME = "Product" 
ID = 2 
ACCESS = READ-ONLY 
STORAGE = SPECIFIC 
TYPE = STRING(64) 
VALUE = "\tcc1-pgh10.tcc1.local\swshare$\Packages\NetAgent_10.0.3361\exe"
END ATTRIBUTE

The value is limited to 64symb including path. It will be working properly only on a local machine without using UNC paths

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top