Exemplo n.º 1
0
 /// <summary>
 /// Look for installed applications with names containing 'Word' and showing their properties (installed location, version, ...)
 /// </summary>
 /// <param name="args"></param>
 static void Main(string[] args)
 {
     foreach (var p in InstalledProduct.EnumerateInstalledProducts())
     {
         Console.Out.WriteLine("{0}\r\n-------------------------------------------------------------\r\n{1}", p.GUID, PrintProduct(p));
     }
 }
Exemplo n.º 2
0
        public void SetKeyValue(InstalledProduct installedProduct)
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey(keyPath, true);
            if (key == null)
                key = CreateBaseKey();

            if (key != null)
                key.SetValue(null, GetProductString(installedProduct));

            key.Close();
        }
    private void OnInstallerStatusUpdated(object sender, Microsoft.Web.PlatformInstaller.InstallStatusEventArgs e)
    {
        var installerContext = e.InstallerContext;
        var msDeployPackage  = e.InstallerContext.Installer.MSDeployPackage;
        InstalledProduct product;

        if (!Products.TryGetValue(installerContext.ProductName, out product))
        {
            product = new InstalledProduct()
            {
                Name      = installerContext.ProductName,
                ProductId = installerContext.Id
            };

            Products.Add(installerContext.ProductName, product);
        }

        if (msDeployPackage != null)
        {
            product.IsWebSite  = true;
            product.Parameters = msDeployPackage.SetParameters;
            product.Site       = msDeployPackage.Site;
            product.AppPath    = msDeployPackage.AppPath;
        }

        switch (e.InstallerContext.ReturnCode.Status)
        {
        case InstallReturnCodeStatus.Success:
            break;

        case InstallReturnCodeStatus.SuccessRebootRequired:
            product.RequiresReboot = true;
            product.HasError       = true;
            break;

        case InstallReturnCodeStatus.Failure:
            product.HasError = true;
            product.Message  = e.InstallerContext.ReturnCode.DetailedInformation;
            break;

        case InstallReturnCodeStatus.FailureRebootRequired:
            product.RequiresReboot = true;
            product.HasError       = true;
            product.Message        = e.InstallerContext.ReturnCode.DetailedInformation;
            break;

        case InstallReturnCodeStatus.None:
            break;
        }
    }
Exemplo n.º 4
0
        static string PrintProduct(InstalledProduct product)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var p in product.GetType().GetProperties())
            {
                try
                {
                    sb.AppendFormat("{0}: {1}\r\n", p.Name, p.GetValue(product));
                }
                catch
                { }
            }

            return(sb.ToString());
        }
Exemplo n.º 5
0
 /// <summary>
 /// Look for installed applications with names containing 'Word' and showing their properties (installed location, version, ...)
 /// </summary>
 /// <param name="args"></param>
 static void Main(string[] args)
 {
     foreach (var p in InstalledProduct.Enumerate())
     {
         try
         {
             if (p.InstalledProductName.Contains("Word"))
             {
                 Console.Out.WriteLine("{0}\r\n-------------------------------------------------------------\r\n{1}", p.GUID, p.ToString());
             }
         }
         catch (Exception ex)
         {
             // Some products might throw an exception trying to access InstalledProductName propoerty.
         }
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Checks to see if Plex Media Server is installed.
 /// </summary>
 /// <returns>
 /// True if it is installed, false if it isn't.
 /// </returns>
 private bool IsInstalled()
 {
     return((InstalledProduct.Enumerate()
             .Where(product => product.DisplayName == DisplayName)).Any());
 }
Exemplo n.º 7
0
		protected static string GetProductString( InstalledProduct installedProduct )
		{
			return installedProduct.ToString();
		}