ManagementScope scope; ConnectionOptions connectionOptions = new ConnectionOptions { Authentication = AuthenticationLevel.PacketPrivacy, Impersonation = ImpersonationLevel.Impersonate }; /* connOptions = new ConnectionOptions(); connOptions.Impersonation = ImpersonationLevel.Impersonate; connOptions.EnablePrivileges = true; connOptions.Username = "DOMAIN" + "\\" + "user"; connOptions.Password = "password"; */ scope = new ManagementScope(@"\\" + "KA16500" + @"\ROOT\CIMV2", connectionOptions); scope.Connect(); ManagementPath p = new ManagementPath("Win32_Product"); ManagementClass classInstance = new ManagementClass(scope, p, null); ManagementBaseObject inParams = classInstance.GetMethodParameters("Install"); inParams["AllUsers"] = true; inParams["Options"] = string.Empty; inParams["PackageLocation"] = @"\\ka16500\sharePoint\1.msi"; ManagementBaseObject outParams = classInstance.InvokeMethod("Install", inParams, null); string retVal = outParams["ReturnValue"].ToString();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)