Exemple #1
0
        private static void UpdateArpEntry(SubscriptionState subState, ShellExposureInformation shellExposureInformation)
        {
            DefinitionIdentity subscriptionId            = subState.SubscriptionId;
            string             str                       = string.Format(CultureInfo.InvariantCulture, "rundll32.exe dfshim.dll,ShArpMaintain {0}", new object[] { subscriptionId.ToString() });
            string             str2                      = string.Format(CultureInfo.InvariantCulture, "dfshim.dll,2", new object[0]);
            AssemblyManifest   currentDeploymentManifest = subState.CurrentDeploymentManifest;
            Description        effectiveDescription      = subState.EffectiveDescription;

            using (RegistryKey key = UninstallRoot.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
            {
                using (RegistryKey key2 = key.CreateSubKey(GenerateArpKeyName(subscriptionId)))
                {
                    string[] strArray = new string[] {
                        "DisplayName", shellExposureInformation.ARPDisplayName, "DisplayIcon", str2, "DisplayVersion", currentDeploymentManifest.Identity.Version.ToString(), "Publisher", effectiveDescription.FilteredPublisher, "UninstallString", str, "HelpLink", effectiveDescription.SupportUrl, "UrlUpdateInfo", subState.DeploymentProviderUri.AbsoluteUri, "ShortcutFolderName", shellExposureInformation.AppVendor,
                        "ShortcutFileName", shellExposureInformation.AppProduct, "ShortcutSuiteName", shellExposureInformation.AppSuiteName, "SupportShortcutFileName", shellExposureInformation.AppSupportShortcut, "ShortcutAppId", shellExposureInformation.ShortcutAppId
                    };
                    Logger.AddInternalState("Updating ARP entry.");
                    for (int i = strArray.Length - 2; i >= 0; i -= 2)
                    {
                        string name = strArray[i];
                        string str4 = strArray[i + 1];
                        if (str4 != null)
                        {
                            key2.SetValue(name, str4);
                        }
                        else
                        {
                            key2.DeleteValue(name, false);
                        }
                    }
                }
            }
        }
Exemple #2
0
 public static void UpdateSubscriptionShellExposure(SubscriptionState subState)
 {
     using (subState.SubscriptionStore.AcquireStoreWriterLock())
     {
         ShellExposureInformation shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
         UpdateShortcuts(subState, ref shellExposureInformation);
         UpdateShellExtensions(subState, ref shellExposureInformation);
         UpdateArpEntry(subState, shellExposureInformation);
     }
 }
Exemple #3
0
        internal static void RemovePins(SubscriptionState subState)
        {
            Logger.AddInternalState("Attempting to remove shell pins.");
            ShellExposureInformation information = ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);

            if (information == null)
            {
                Logger.AddInternalState("shellExposureInformation is null.");
            }
            else if (System.IO.File.Exists(information.ApplicationShortcutPath))
            {
                UnpinShortcut(information.ApplicationShortcutPath);
            }
        }
Exemple #4
0
 private static void GenerateAppShortcut(SubscriptionState subState, ShellExposureInformation shellExposureInformation)
 {
     using (StreamWriter writer = new StreamWriter(shellExposureInformation.ApplicationShortcutPath, false, Encoding.Unicode))
     {
         writer.Write("{0}#{1}", subState.DeploymentProviderUri.AbsoluteUri, subState.SubscriptionId.ToString());
     }
     Logger.AddInternalState("Shortcut file created: " + shellExposureInformation.ApplicationShortcutPath);
     if (subState.CurrentDeploymentManifest.Deployment.CreateDesktopShortcut)
     {
         using (StreamWriter writer2 = new StreamWriter(shellExposureInformation.DesktopShortcutPath, false, Encoding.Unicode))
         {
             writer2.Write("{0}#{1}", subState.DeploymentProviderUri.AbsoluteUri, subState.SubscriptionId.ToString());
         }
         Logger.AddInternalState("Desktop Shortcut file created: " + shellExposureInformation.DesktopShortcutPath);
     }
 }
Exemple #5
0
 private static void RemoveShortcuts(ShellExposureInformation shellExposureInformation)
 {
     try
     {
         if (System.IO.File.Exists(shellExposureInformation.ApplicationShortcutPath))
         {
             System.IO.File.Delete(shellExposureInformation.ApplicationShortcutPath);
         }
         if (System.IO.File.Exists(shellExposureInformation.SupportShortcutPath))
         {
             System.IO.File.Delete(shellExposureInformation.SupportShortcutPath);
         }
         if (System.IO.File.Exists(shellExposureInformation.DesktopShortcutPath))
         {
             System.IO.File.Delete(shellExposureInformation.DesktopShortcutPath);
         }
         if (Directory.Exists(shellExposureInformation.ApplicationFolderPath))
         {
             string[] files       = Directory.GetFiles(shellExposureInformation.ApplicationFolderPath);
             string[] directories = Directory.GetDirectories(shellExposureInformation.ApplicationFolderPath);
             if ((files.Length == 0) && (directories.Length == 0))
             {
                 Directory.Delete(shellExposureInformation.ApplicationFolderPath);
             }
         }
         if (Directory.Exists(shellExposureInformation.ApplicationRootFolderPath))
         {
             string[] strArray3 = Directory.GetFiles(shellExposureInformation.ApplicationRootFolderPath);
             string[] strArray4 = Directory.GetDirectories(shellExposureInformation.ApplicationRootFolderPath);
             if ((strArray3.Length == 0) && (strArray4.Length == 0))
             {
                 Directory.Delete(shellExposureInformation.ApplicationRootFolderPath);
             }
         }
         Logger.AddInternalState("Removed shortcut entries : " + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath + "," + shellExposureInformation.ApplicationFolderPath + "," + shellExposureInformation.ApplicationRootFolderPath);
     }
     catch (IOException exception)
     {
         throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_ShortcutRemovalFailure"), exception);
     }
     catch (UnauthorizedAccessException exception2)
     {
         throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_ShortcutRemovalFailure"), exception2);
     }
 }
Exemple #6
0
        private static void GenerateSupportShortcut(SubscriptionState subState, ShellExposureInformation shellExposureInformation)
        {
            Description effectiveDescription = subState.EffectiveDescription;

            if (effectiveDescription.SupportUri != null)
            {
                using (StreamWriter writer = new StreamWriter(shellExposureInformation.SupportShortcutPath, false, Encoding.ASCII))
                {
                    writer.WriteLine("[Default]");
                    writer.WriteLine("BASEURL=" + effectiveDescription.SupportUri.AbsoluteUri);
                    writer.WriteLine("[InternetShortcut]");
                    writer.WriteLine("URL=" + effectiveDescription.SupportUri.AbsoluteUri);
                    writer.WriteLine();
                    writer.WriteLine("IconFile=" + System.Deployment.Application.PathHelper.ShortShimDllPath);
                    writer.WriteLine("IconIndex=" + 0.ToString(CultureInfo.InvariantCulture));
                    writer.WriteLine();
                }
                Logger.AddInternalState("Support shortcut file created: " + shellExposureInformation.SupportShortcutPath);
            }
        }
Exemple #7
0
        public static void UpdateShellExtensions(SubscriptionState subState, ref ShellExposureInformation shellExposureInformation)
        {
            string productName = null;

            if (shellExposureInformation != null)
            {
                productName = shellExposureInformation.AppProduct;
            }
            if (productName == null)
            {
                productName = subState.SubscriptionId.Name;
            }
            if (subState.PreviousBind != null)
            {
                Logger.AddInternalState("Removing file associations if existed for the previous version.");
                RemoveShellExtensions(subState.SubscriptionId, subState.PreviousApplicationManifest, productName);
            }
            Logger.AddInternalState("Registering file associations if there is any in the manifest for the new version. ");
            AddShellExtensions(subState.SubscriptionId, subState.DeploymentProviderUri, subState.CurrentApplicationManifest);
            System.Deployment.Application.NativeMethods.SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
        }
Exemple #8
0
 public static void RemoveSubscriptionShellExposure(SubscriptionState subState)
 {
     using (subState.SubscriptionStore.AcquireStoreWriterLock())
     {
         DefinitionIdentity subscriptionId = subState.SubscriptionId;
         bool flag = false;
         ShellExposureInformation shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(subscriptionId);
         if (shellExposureInformation == null)
         {
             flag = true;
         }
         else
         {
             for (int i = 1; i <= 2; i++)
             {
                 try
                 {
                     RemoveShortcuts(shellExposureInformation);
                     break;
                 }
                 catch (DeploymentException)
                 {
                     Logger.AddInternalState("Remove shortcut entries Failed: " + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath + "," + shellExposureInformation.ApplicationFolderPath + "," + shellExposureInformation.ApplicationRootFolderPath);
                     if (i >= 2)
                     {
                         throw;
                     }
                     Thread.Sleep(0x3e8);
                 }
             }
         }
         RemoveArpEntry(subscriptionId);
         if (flag)
         {
             throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_ShortcutRemovalFailureDueToInvalidPublisherProduct"));
         }
     }
 }
 private static void UpdateShortcuts(SubscriptionState subState, ref ShellExposureInformation shellExposureInformation)
 {
     string strA = string.Format("{0}#{1}", subState.DeploymentProviderUri.AbsoluteUri, subState.SubscriptionId.ToString());
     Description effectiveDescription = subState.EffectiveDescription;
     if (shellExposureInformation != null)
     {
         bool flag = true;
         bool flag2 = true;
         bool flag3 = true;
         bool flag4 = true;
         if (string.Compare(effectiveDescription.FilteredPublisher, shellExposureInformation.AppVendor, StringComparison.Ordinal) == 0)
         {
             flag = false;
             if (Utilities.CompareWithNullEqEmpty(effectiveDescription.FilteredSuiteName, shellExposureInformation.AppSuiteName, StringComparison.Ordinal) == 0)
             {
                 flag2 = false;
                 if (string.Compare(effectiveDescription.FilteredProduct, shellExposureInformation.AppProduct, StringComparison.Ordinal) == 0)
                 {
                     flag3 = false;
                     if (string.Compare(strA, shellExposureInformation.ShortcutAppId, StringComparison.Ordinal) == 0)
                     {
                         flag4 = false;
                     }
                 }
             }
         }
         if (((!flag && !flag2) && (!flag3 && !flag4)) && System.IO.File.Exists(shellExposureInformation.ApplicationShortcutPath))
         {
             Logger.AddInternalState("Shortcut folder and files are not updated and application shortcut file already exists: " + shellExposureInformation.ApplicationShortcutPath);
             return;
         }
         if (flag3)
         {
             UnpinShortcut(shellExposureInformation.ApplicationShortcutPath);
             MoveDeleteFile(shellExposureInformation.ApplicationShortcutPath);
             MoveDeleteFile(shellExposureInformation.SupportShortcutPath);
             MoveDeleteFile(shellExposureInformation.DesktopShortcutPath);
             Logger.AddInternalState("Shortcut files deleted:" + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath);
         }
         if (flag2)
         {
             Logger.AddInternalState("Attempt deleting shortcut folder:" + shellExposureInformation.ApplicationFolderPath);
             MoveDeleteEmptyFolder(shellExposureInformation.ApplicationFolderPath);
         }
         if (flag)
         {
             Logger.AddInternalState("Attempt deleting shortcut root folder:" + shellExposureInformation.ApplicationRootFolderPath);
             MoveDeleteEmptyFolder(shellExposureInformation.ApplicationRootFolderPath);
         }
         if ((flag || flag2) || flag3)
         {
             shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, strA);
         }
         else
         {
             Logger.AddInternalState("Shortcut app id has changed. Old value=" + shellExposureInformation.ShortcutAppId + ",New value=" + strA);
             shellExposureInformation.ShortcutAppId = strA;
         }
     }
     else
     {
         shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, strA);
     }
     try
     {
         Logger.AddInternalState("Create the shortcut directory : " + shellExposureInformation.ApplicationFolderPath);
         Directory.CreateDirectory(shellExposureInformation.ApplicationFolderPath);
         GenerateAppShortcut(subState, shellExposureInformation);
         GenerateSupportShortcut(subState, shellExposureInformation);
     }
     catch (Exception)
     {
         RemoveShortcuts(shellExposureInformation);
         throw;
     }
 }
 public static void UpdateShellExtensions(SubscriptionState subState, ref ShellExposureInformation shellExposureInformation)
 {
     string productName = null;
     if (shellExposureInformation != null)
     {
         productName = shellExposureInformation.AppProduct;
     }
     if (productName == null)
     {
         productName = subState.SubscriptionId.Name;
     }
     if (subState.PreviousBind != null)
     {
         Logger.AddInternalState("Removing file associations if existed for the previous version.");
         RemoveShellExtensions(subState.SubscriptionId, subState.PreviousApplicationManifest, productName);
     }
     Logger.AddInternalState("Registering file associations if there is any in the manifest for the new version. ");
     AddShellExtensions(subState.SubscriptionId, subState.DeploymentProviderUri, subState.CurrentApplicationManifest);
     System.Deployment.Application.NativeMethods.SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
 }
 private static void UpdateArpEntry(SubscriptionState subState, ShellExposureInformation shellExposureInformation)
 {
     DefinitionIdentity subscriptionId = subState.SubscriptionId;
     string str = string.Format(CultureInfo.InvariantCulture, "rundll32.exe dfshim.dll,ShArpMaintain {0}", new object[] { subscriptionId.ToString() });
     string str2 = string.Format(CultureInfo.InvariantCulture, "dfshim.dll,2", new object[0]);
     AssemblyManifest currentDeploymentManifest = subState.CurrentDeploymentManifest;
     Description effectiveDescription = subState.EffectiveDescription;
     using (RegistryKey key = UninstallRoot.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
     {
         using (RegistryKey key2 = key.CreateSubKey(GenerateArpKeyName(subscriptionId)))
         {
             string[] strArray = new string[] { 
                 "DisplayName", shellExposureInformation.ARPDisplayName, "DisplayIcon", str2, "DisplayVersion", currentDeploymentManifest.Identity.Version.ToString(), "Publisher", effectiveDescription.FilteredPublisher, "UninstallString", str, "HelpLink", effectiveDescription.SupportUrl, "UrlUpdateInfo", subState.DeploymentProviderUri.AbsoluteUri, "ShortcutFolderName", shellExposureInformation.AppVendor, 
                 "ShortcutFileName", shellExposureInformation.AppProduct, "ShortcutSuiteName", shellExposureInformation.AppSuiteName, "SupportShortcutFileName", shellExposureInformation.AppSupportShortcut, "ShortcutAppId", shellExposureInformation.ShortcutAppId
              };
             Logger.AddInternalState("Updating ARP entry.");
             for (int i = strArray.Length - 2; i >= 0; i -= 2)
             {
                 string name = strArray[i];
                 string str4 = strArray[i + 1];
                 if (str4 != null)
                 {
                     key2.SetValue(name, str4);
                 }
                 else
                 {
                     key2.DeleteValue(name, false);
                 }
             }
         }
     }
 }
 private static void RemoveShortcuts(ShellExposureInformation shellExposureInformation)
 {
     try
     {
         if (System.IO.File.Exists(shellExposureInformation.ApplicationShortcutPath))
         {
             System.IO.File.Delete(shellExposureInformation.ApplicationShortcutPath);
         }
         if (System.IO.File.Exists(shellExposureInformation.SupportShortcutPath))
         {
             System.IO.File.Delete(shellExposureInformation.SupportShortcutPath);
         }
         if (System.IO.File.Exists(shellExposureInformation.DesktopShortcutPath))
         {
             System.IO.File.Delete(shellExposureInformation.DesktopShortcutPath);
         }
         if (Directory.Exists(shellExposureInformation.ApplicationFolderPath))
         {
             string[] files = Directory.GetFiles(shellExposureInformation.ApplicationFolderPath);
             string[] directories = Directory.GetDirectories(shellExposureInformation.ApplicationFolderPath);
             if ((files.Length == 0) && (directories.Length == 0))
             {
                 Directory.Delete(shellExposureInformation.ApplicationFolderPath);
             }
         }
         if (Directory.Exists(shellExposureInformation.ApplicationRootFolderPath))
         {
             string[] strArray3 = Directory.GetFiles(shellExposureInformation.ApplicationRootFolderPath);
             string[] strArray4 = Directory.GetDirectories(shellExposureInformation.ApplicationRootFolderPath);
             if ((strArray3.Length == 0) && (strArray4.Length == 0))
             {
                 Directory.Delete(shellExposureInformation.ApplicationRootFolderPath);
             }
         }
         Logger.AddInternalState("Removed shortcut entries : " + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath + "," + shellExposureInformation.ApplicationFolderPath + "," + shellExposureInformation.ApplicationRootFolderPath);
     }
     catch (IOException exception)
     {
         throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_ShortcutRemovalFailure"), exception);
     }
     catch (UnauthorizedAccessException exception2)
     {
         throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_ShortcutRemovalFailure"), exception2);
     }
 }
 private static void GenerateSupportShortcut(SubscriptionState subState, ShellExposureInformation shellExposureInformation)
 {
     Description effectiveDescription = subState.EffectiveDescription;
     if (effectiveDescription.SupportUri != null)
     {
         using (StreamWriter writer = new StreamWriter(shellExposureInformation.SupportShortcutPath, false, Encoding.ASCII))
         {
             writer.WriteLine("[Default]");
             writer.WriteLine("BASEURL=" + effectiveDescription.SupportUri.AbsoluteUri);
             writer.WriteLine("[InternetShortcut]");
             writer.WriteLine("URL=" + effectiveDescription.SupportUri.AbsoluteUri);
             writer.WriteLine();
             writer.WriteLine("IconFile=" + System.Deployment.Application.PathHelper.ShortShimDllPath);
             writer.WriteLine("IconIndex=" + 0.ToString(CultureInfo.InvariantCulture));
             writer.WriteLine();
         }
         Logger.AddInternalState("Support shortcut file created: " + shellExposureInformation.SupportShortcutPath);
     }
 }
 private static void GenerateAppShortcut(SubscriptionState subState, ShellExposureInformation shellExposureInformation)
 {
     using (StreamWriter writer = new StreamWriter(shellExposureInformation.ApplicationShortcutPath, false, Encoding.Unicode))
     {
         writer.Write("{0}#{1}", subState.DeploymentProviderUri.AbsoluteUri, subState.SubscriptionId.ToString());
     }
     Logger.AddInternalState("Shortcut file created: " + shellExposureInformation.ApplicationShortcutPath);
     if (subState.CurrentDeploymentManifest.Deployment.CreateDesktopShortcut)
     {
         using (StreamWriter writer2 = new StreamWriter(shellExposureInformation.DesktopShortcutPath, false, Encoding.Unicode))
         {
             writer2.Write("{0}#{1}", subState.DeploymentProviderUri.AbsoluteUri, subState.SubscriptionId.ToString());
         }
         Logger.AddInternalState("Desktop Shortcut file created: " + shellExposureInformation.DesktopShortcutPath);
     }
 }
Exemple #15
0
        private static void UpdateShortcuts(SubscriptionState subState, ref ShellExposureInformation shellExposureInformation)
        {
            string      strA = string.Format("{0}#{1}", subState.DeploymentProviderUri.AbsoluteUri, subState.SubscriptionId.ToString());
            Description effectiveDescription = subState.EffectiveDescription;

            if (shellExposureInformation != null)
            {
                bool flag  = true;
                bool flag2 = true;
                bool flag3 = true;
                bool flag4 = true;
                if (string.Compare(effectiveDescription.FilteredPublisher, shellExposureInformation.AppVendor, StringComparison.Ordinal) == 0)
                {
                    flag = false;
                    if (Utilities.CompareWithNullEqEmpty(effectiveDescription.FilteredSuiteName, shellExposureInformation.AppSuiteName, StringComparison.Ordinal) == 0)
                    {
                        flag2 = false;
                        if (string.Compare(effectiveDescription.FilteredProduct, shellExposureInformation.AppProduct, StringComparison.Ordinal) == 0)
                        {
                            flag3 = false;
                            if (string.Compare(strA, shellExposureInformation.ShortcutAppId, StringComparison.Ordinal) == 0)
                            {
                                flag4 = false;
                            }
                        }
                    }
                }
                if (((!flag && !flag2) && (!flag3 && !flag4)) && System.IO.File.Exists(shellExposureInformation.ApplicationShortcutPath))
                {
                    Logger.AddInternalState("Shortcut folder and files are not updated and application shortcut file already exists: " + shellExposureInformation.ApplicationShortcutPath);
                    return;
                }
                if (flag3)
                {
                    UnpinShortcut(shellExposureInformation.ApplicationShortcutPath);
                    MoveDeleteFile(shellExposureInformation.ApplicationShortcutPath);
                    MoveDeleteFile(shellExposureInformation.SupportShortcutPath);
                    MoveDeleteFile(shellExposureInformation.DesktopShortcutPath);
                    Logger.AddInternalState("Shortcut files deleted:" + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath);
                }
                if (flag2)
                {
                    Logger.AddInternalState("Attempt deleting shortcut folder:" + shellExposureInformation.ApplicationFolderPath);
                    MoveDeleteEmptyFolder(shellExposureInformation.ApplicationFolderPath);
                }
                if (flag)
                {
                    Logger.AddInternalState("Attempt deleting shortcut root folder:" + shellExposureInformation.ApplicationRootFolderPath);
                    MoveDeleteEmptyFolder(shellExposureInformation.ApplicationRootFolderPath);
                }
                if ((flag || flag2) || flag3)
                {
                    shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, strA);
                }
                else
                {
                    Logger.AddInternalState("Shortcut app id has changed. Old value=" + shellExposureInformation.ShortcutAppId + ",New value=" + strA);
                    shellExposureInformation.ShortcutAppId = strA;
                }
            }
            else
            {
                shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, strA);
            }
            try
            {
                Logger.AddInternalState("Create the shortcut directory : " + shellExposureInformation.ApplicationFolderPath);
                Directory.CreateDirectory(shellExposureInformation.ApplicationFolderPath);
                GenerateAppShortcut(subState, shellExposureInformation);
                GenerateSupportShortcut(subState, shellExposureInformation);
            }
            catch (Exception)
            {
                RemoveShortcuts(shellExposureInformation);
                throw;
            }
        }