Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows Management Instrumentation msi安装远程计算机_C#_Windows Installer_Wmi_Remote Desktop - Fatal编程技术网

C# Windows Management Instrumentation msi安装远程计算机

C# Windows Management Instrumentation msi安装远程计算机,c#,windows-installer,wmi,remote-desktop,C#,Windows Installer,Wmi,Remote Desktop,我正在尝试在远程计算机上安装msi,在使用win32_产品的methode安装时,我更改了DCOM配置以从我的计算机获取访问权限。安装失败,返回输出1601(这意味着无法访问Windows Installer服务) 我在网上做了一些研究,并使用services.msc手动运行服务 并且没有msiexec/unr和msiexec/register,仍然不工作 ps:两台机器都在windows 10上运行 这是我的密码 Ps:我使用了与win32_Bios相同的代码来获取SerialNumber,它

我正在尝试在远程计算机上安装msi,在使用win32_产品的methode安装时,我更改了DCOM配置以从我的计算机获取访问权限。安装失败,返回输出1601(这意味着无法访问Windows Installer服务) 我在网上做了一些研究,并使用services.msc手动运行服务 并且没有
msiexec/unr
msiexec/register
,仍然不工作 ps:两台机器都在windows 10上运行 这是我的密码

Ps:我使用了与win32_Bios相同的代码来获取SerialNumber,它可以正常工作

try

        {
\\machine is the name of the computer

            string PackageLocation = @"\\" + machine + msi;

            ConnectionOptions connection = new ConnectionOptions();

            connection.Username = username;

            connection.Password = password;

            connection.Impersonation = ImpersonationLevel.Impersonate;

            connection.Authentication = AuthenticationLevel.Default;
            connection.EnablePrivileges = true;
            //define the WMI root name space

            ManagementScope scope =

            new ManagementScope(@"\\" + machine + @"\root\CIMV2", connection);

            //define path for the WMI class

            ManagementPath p =

            new ManagementPath("Win32_Product");

            //define new instance

            ManagementClass classInstance = new ManagementClass(scope, p, null);


            // Obtain in-parameters for the method

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

            // Add the input parameters.

            inParams["AllUsers"] = true; //to install for all users

            inParams["Options"] = ""; //paramters must be in the format “property=setting“
            inParams["PackageLocation"] = @"c:\install\installer.msi";
//source file must be on the remote machine
            // Execute the method and obtain the return values.

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

            // List outParams

            string retVal = outParams["ReturnValue"].ToString();

            string msg = null;

            switch (retVal)

            {
                case "0":

                    msg = "The installation completed successfully.";

                    break;

                case "2":

                    msg = "The system cannot find the specified file. \n\r\n\r" + msi;

                    break;

                case "3":

                    msg = "The system cannot find the path specified. \n\r\n\r" + msi;

                    break;

                case "1619":

                    msg = "This installation package \n\r\n\r " + msi + "\n\r\n\rcould not be opened, please verify that it is accessible.";

                    break;

                case "1620":

                    msg = "This installation package \n\r\n\r " + msi + "\n\r\n\rcould not be opened, please verify that it is a valid MSI package.";

                    break;

                default:

                    msg = "Please see... \n\r\n\r http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/error_codes.asp \n\r\n\rError code: " + retVal;

                    break;
            }

            // Display outParams

            Console.WriteLine(msg, "Installation report");
        }
        catch (ManagementException me)

        {
            Console.WriteLine(me.Message + "Management Exception");
        }
        catch (COMException ioe)

        {
            Console.WriteLine(ioe.Message, "COM Exception");
        }
    }

您是否已在目标计算机上的事件日志中查找MSI安装程序条目?它们可能会出现在应用程序事件中,Logi没有找到它