Esempio n. 1
0
        public static string UninstallMsi(string productCode, string computerName, ConnectionOptions connectionOptions)
        {
            //uses WMI to uninstall the application, then deletes the MSI from the Management Server path

            StringBuilder log = new StringBuilder();

            string selectQuery = string.Format("Select * FROM Win32_Product Where IdentifyingNumber = '{0}'", GuidUtilities.AddBracesToGuid(productCode));

            //ConnectionOptions oConn = new ConnectionOptions();
            //oConn.Username = "******";
            //oConn.Password = "******";

            ManagementObjectCollection products = WMIUtilities.QueryWMI(selectQuery, computerName, connectionOptions);

            log.AppendLine(string.Format("Found [{0}] matches", products.Count));
            foreach (ManagementObject product in products)
            {
                log.Append(string.Format("Uninstalling '{0}'", product.Properties["Name"].ToString()));

                var result = product.InvokeMethod("Uninstall", null);
                log.Append(string.Format("The Uninstall method result is {0}", result.ToString()));
            }
            return(log.ToString());
        }
Esempio n. 2
0
        /*
         * public static string GetDeployedIpVersion(string productCode, string computerName)
         * {
         *  string version = string.Empty;
         *
         *  string uninstallKey = GuidUtilities.AddBracesToGuid(productCode);
         *
         *  RegistryKey key;
         *
         *  if ((string.IsNullOrEmpty(computerName) || (Utilities.IsLocalComputer(computerName))))
         *  {
         *      key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
         *  }
         *  else
         *  {
         *      key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName, RegistryView.Registry64);
         *  }
         *  string baseKey = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\";
         *  RegistryKey ipKey = key.OpenSubKey(baseKey + uninstallKey);
         *  if (null == ipKey)
         *  {
         *      return string.Empty;
         *  }
         *  object versionObj = ipKey.GetValue("DisplayVersion");
         *  if (null != versionObj)
         *  {
         *      return versionObj.ToString();
         *  }
         *  return string.Empty;
         * }
         */
        public static bool UnregisterIP(string packID, string computerName, ConnectionOptions connectionOptions)
        {
            string oipFile = IPUtilities.GetOIPFilePath(packID);

            return(WMIUtilities.DeleteFileUsingWMI(oipFile, computerName, connectionOptions));
        }