Exemplo n.º 1
0
 private static void RemoveShortcuts(ShellExposure.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) && (Directory.GetFiles(shellExposureInformation.ApplicationFolderPath).Length == 0 && Directory.GetDirectories(shellExposureInformation.ApplicationFolderPath).Length == 0))
         {
             Directory.Delete(shellExposureInformation.ApplicationFolderPath);
         }
         if (Directory.Exists(shellExposureInformation.ApplicationRootFolderPath) && (Directory.GetFiles(shellExposureInformation.ApplicationRootFolderPath).Length == 0 && Directory.GetDirectories(shellExposureInformation.ApplicationRootFolderPath).Length == 0))
         {
             Directory.Delete(shellExposureInformation.ApplicationRootFolderPath);
         }
         Logger.AddInternalState("Removed shortcut entries : " + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath + "," + shellExposureInformation.ApplicationFolderPath + "," + shellExposureInformation.ApplicationRootFolderPath);
     }
     catch (IOException ex)
     {
         throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_ShortcutRemovalFailure"), (Exception)ex);
     }
     catch (UnauthorizedAccessException ex)
     {
         throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_ShortcutRemovalFailure"), (Exception)ex);
     }
 }
Exemplo n.º 2
0
 public static void UpdateSubscriptionShellExposure(SubscriptionState subState)
 {
     using (subState.SubscriptionStore.AcquireStoreWriterLock())
     {
         ShellExposure.ShellExposureInformation exposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
         ShellExposure.UpdateShortcuts(subState, ref exposureInformation);
         ShellExposure.UpdateShellExtensions(subState, ref exposureInformation);
         ShellExposure.UpdateArpEntry(subState, exposureInformation);
     }
 }
Exemplo n.º 3
0
 private static void GenerateAppShortcut(SubscriptionState subState, ShellExposure.ShellExposureInformation shellExposureInformation)
 {
     using (StreamWriter streamWriter = new StreamWriter(shellExposureInformation.ApplicationShortcutPath, false, Encoding.Unicode))
         streamWriter.Write("{0}#{1}", (object)subState.DeploymentProviderUri.AbsoluteUri, (object)subState.SubscriptionId.ToString());
     Logger.AddInternalState("Shortcut file created: " + shellExposureInformation.ApplicationShortcutPath);
     if (!subState.CurrentDeploymentManifest.Deployment.CreateDesktopShortcut)
     {
         return;
     }
     using (StreamWriter streamWriter = new StreamWriter(shellExposureInformation.DesktopShortcutPath, false, Encoding.Unicode))
         streamWriter.Write("{0}#{1}", (object)subState.DeploymentProviderUri.AbsoluteUri, (object)subState.SubscriptionId.ToString());
     Logger.AddInternalState("Desktop Shortcut file created: " + shellExposureInformation.DesktopShortcutPath);
 }
Exemplo n.º 4
0
            public static ShellExposure.ShellExposureInformation CreateShellExposureInformation(string publisher, string suiteName, string product, string shortcutAppId)
            {
                ShellExposure.ShellExposureInformation exposureInformation = new ShellExposure.ShellExposureInformation();
                string path1_1 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), publisher);
                string path1_2 = path1_1;

                if (!string.IsNullOrEmpty(suiteName))
                {
                    path1_2 = Path.Combine(path1_1, suiteName);
                }
                string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

                for (int index = 0; index != int.MaxValue; ++index)
                {
                    string str;
                    if (index == 0)
                    {
                        str = string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ShellExposure_DisplayStringNoIndex"), new object[1]
                        {
                            (object)product
                        });
                    }
                    else
                    {
                        str = string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ShellExposure_DisplayStringWithIndex"), new object[2]
                        {
                            (object)product,
                            (object)index
                        });
                    }
                    string path1 = Path.Combine(path1_2, str + ".appref-ms");
                    string path2 = Path.Combine(folderPath, str + ".appref-ms");
                    if (!System.IO.File.Exists(path1) && !System.IO.File.Exists(path2))
                    {
                        exposureInformation._appVendor                 = publisher;
                        exposureInformation._appProduct                = str;
                        exposureInformation._appSuiteName              = suiteName;
                        exposureInformation._applicationFolderPath     = path1_2;
                        exposureInformation._applicationRootFolderPath = path1_1;
                        exposureInformation._applicationShortcutPath   = path1;
                        exposureInformation._desktopShortcutPath       = path2;
                        exposureInformation._appSupportShortcut        = string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("SupportUrlFormatter"), new object[1] {
                            (object)str
                        });
                        exposureInformation._supportShortcutPath = Path.Combine(path1_2, exposureInformation._appSupportShortcut + ".url");
                        exposureInformation._shortcutAppId       = shortcutAppId;
                        return(exposureInformation);
                    }
                }
                throw new OverflowException();
            }
Exemplo n.º 5
0
            public static ShellExposure.ShellExposureInformation CreateShellExposureInformation(string publisher, string suiteName, string product, string shortcutAppId)
            {
                ShellExposure.ShellExposureInformation information = new ShellExposure.ShellExposureInformation();
                string str  = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), publisher);
                string str2 = str;

                if (!string.IsNullOrEmpty(suiteName))
                {
                    str2 = Path.Combine(str, suiteName);
                }
                string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string str4       = null;
                string path       = null;
                string str6       = null;
                int    num        = 0;

                num = 0;
Label_003B:
                switch (num)
                {
                case 0x7fffffff:
                    throw new OverflowException();

                case 0:
                    str4 = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ShellExposure_DisplayStringNoIndex"), new object[] { product });
                    break;

                default:
                    str4 = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ShellExposure_DisplayStringWithIndex"), new object[] { product, num });
                    break;
                }
                path = Path.Combine(str2, str4 + ".appref-ms");
                str6 = Path.Combine(folderPath, str4 + ".appref-ms");
                if (System.IO.File.Exists(path) || System.IO.File.Exists(str6))
                {
                    num++;
                    goto Label_003B;
                }
                information._appVendor                 = publisher;
                information._appProduct                = str4;
                information._appSuiteName              = suiteName;
                information._applicationFolderPath     = str2;
                information._applicationRootFolderPath = str;
                information._applicationShortcutPath   = path;
                information._desktopShortcutPath       = str6;
                information._appSupportShortcut        = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("SupportUrlFormatter"), new object[] { str4 });
                information._supportShortcutPath       = Path.Combine(str2, information._appSupportShortcut + ".url");
                information._shortcutAppId             = shortcutAppId;
                return(information);
            }
Exemplo n.º 6
0
 internal static void RemovePins(SubscriptionState subState)
 {
     Logger.AddInternalState("Attempting to remove shell pins.");
     ShellExposure.ShellExposureInformation exposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
     if (exposureInformation == null)
     {
         Logger.AddInternalState("shellExposureInformation is null.");
     }
     else
     {
         if (!System.IO.File.Exists(exposureInformation.ApplicationShortcutPath))
         {
             return;
         }
         ShellExposure.UnpinShortcut(exposureInformation.ApplicationShortcutPath);
     }
 }
Exemplo n.º 7
0
            public static ShellExposure.ShellExposureInformation CreateShellExposureInformation(DefinitionIdentity subscriptionIdentity)
            {
                ShellExposure.ShellExposureInformation exposureInformation = (ShellExposure.ShellExposureInformation)null;
                string path2_1 = (string)null;
                string str1    = (string)null;
                string path2_2 = (string)null;
                string str2    = (string)null;
                string str3    = "";

                using (RegistryKey registryKey1 = ShellExposure.UninstallRoot.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"))
                {
                    if (registryKey1 != null)
                    {
                        using (RegistryKey registryKey2 = registryKey1.OpenSubKey(ShellExposure.GenerateArpKeyName(subscriptionIdentity)))
                        {
                            if (registryKey2 != null)
                            {
                                path2_1 = registryKey2.GetValue("ShortcutFolderName") as string;
                                str1    = registryKey2.GetValue("ShortcutFileName") as string;
                                path2_2 = registryKey2.GetValue("ShortcutSuiteName") == null ? "" : registryKey2.GetValue("ShortcutSuiteName") as string;
                                str2    = registryKey2.GetValue("SupportShortcutFileName") as string;
                                str3    = registryKey2.GetValue("ShortcutAppId") == null ? "" : registryKey2.GetValue("ShortcutAppId") as string;
                            }
                        }
                    }
                }
                if (path2_1 != null && str1 != null && str2 != null)
                {
                    exposureInformation = new ShellExposure.ShellExposureInformation();
                    exposureInformation._applicationRootFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), path2_1);
                    exposureInformation._applicationFolderPath     = !string.IsNullOrEmpty(path2_2) ? Path.Combine(exposureInformation._applicationRootFolderPath, path2_2) : exposureInformation._applicationRootFolderPath;
                    exposureInformation._applicationShortcutPath   = Path.Combine(exposureInformation._applicationFolderPath, str1 + ".appref-ms");
                    exposureInformation._supportShortcutPath       = Path.Combine(exposureInformation._applicationFolderPath, str2 + ".url");
                    exposureInformation._desktopShortcutPath       = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), str1 + ".appref-ms");
                    exposureInformation._appVendor          = path2_1;
                    exposureInformation._appProduct         = str1;
                    exposureInformation._appSupportShortcut = str2;
                    exposureInformation._shortcutAppId      = str3;
                    exposureInformation._appSuiteName       = path2_2;
                }
                return(exposureInformation);
            }
Exemplo n.º 8
0
 public static void RemoveSubscriptionShellExposure(SubscriptionState subState)
 {
     using (subState.SubscriptionStore.AcquireStoreWriterLock())
     {
         DefinitionIdentity subscriptionId = subState.SubscriptionId;
         bool flag = false;
         ShellExposure.ShellExposureInformation exposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subscriptionId);
         if (exposureInformation == null)
         {
             flag = true;
         }
         else
         {
             for (int index = 1; index <= 2; ++index)
             {
                 try
                 {
                     ShellExposure.RemoveShortcuts(exposureInformation);
                     break;
                 }
                 catch (DeploymentException ex)
                 {
                     Logger.AddInternalState("Remove shortcut entries Failed: " + exposureInformation.ApplicationShortcutPath + "," + exposureInformation.SupportShortcutPath + "," + exposureInformation.DesktopShortcutPath + "," + exposureInformation.ApplicationFolderPath + "," + exposureInformation.ApplicationRootFolderPath);
                     if (index < 2)
                     {
                         Thread.Sleep(1000);
                     }
                     else if (!(ex.InnerException is UnauthorizedAccessException))
                     {
                         throw;
                     }
                 }
             }
         }
         ShellExposure.RemoveArpEntry(subscriptionId);
         if (flag)
         {
             throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_ShortcutRemovalFailureDueToInvalidPublisherProduct"));
         }
     }
 }
Exemplo n.º 9
0
        public static void UpdateShellExtensions(SubscriptionState subState, ref ShellExposure.ShellExposureInformation shellExposureInformation)
        {
            string productName = (string)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.");
                ShellExposure.RemoveShellExtensions(subState.SubscriptionId, subState.PreviousApplicationManifest, productName);
            }
            Logger.AddInternalState("Registering file associations if there is any in the manifest for the new version. ");
            ShellExposure.AddShellExtensions(subState.SubscriptionId, subState.DeploymentProviderUri, subState.CurrentApplicationManifest);
            NativeMethods.SHChangeNotify(134217728, 0U, IntPtr.Zero, IntPtr.Zero);
        }
Exemplo n.º 10
0
        private static void GenerateSupportShortcut(SubscriptionState subState, ShellExposure.ShellExposureInformation shellExposureInformation)
        {
            Description effectiveDescription = subState.EffectiveDescription;

            if (!(effectiveDescription.SupportUri != (Uri)null))
            {
                return;
            }
            using (StreamWriter streamWriter = new StreamWriter(shellExposureInformation.SupportShortcutPath, false, Encoding.ASCII))
            {
                streamWriter.WriteLine("[Default]");
                streamWriter.WriteLine("BASEURL=" + effectiveDescription.SupportUri.AbsoluteUri);
                streamWriter.WriteLine("[InternetShortcut]");
                streamWriter.WriteLine("URL=" + effectiveDescription.SupportUri.AbsoluteUri);
                streamWriter.WriteLine();
                streamWriter.WriteLine("IconFile=" + PathHelper.ShortShimDllPath);
                streamWriter.WriteLine("IconIndex=" + 0.ToString((IFormatProvider)CultureInfo.InvariantCulture));
                streamWriter.WriteLine();
            }
            Logger.AddInternalState("Support shortcut file created: " + shellExposureInformation.SupportShortcutPath);
        }
 public void CommitApplication(ref SubscriptionState subState, CommitApplicationParams commitParams)
 {
     Logger.AddMethodCall("CommitApplication called.");
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         if (commitParams.CommitDeploy)
         {
             Logger.AddInternalState("Commiting Deployment :  subscription metadata.");
             UriHelper.ValidateSupportedScheme(commitParams.DeploySourceUri);
             this.CheckDeploymentSubscriptionState(subState, commitParams.DeployManifest);
             this.ValidateFileAssoctiation(subState, commitParams);
             if (commitParams.IsUpdate && !commitParams.IsUpdateInPKTGroup)
             {
                 CheckInstalled(subState);
             }
         }
         if (commitParams.CommitApp)
         {
             Logger.AddInternalState("Commiting Application:  application binaries.");
             UriHelper.ValidateSupportedScheme(commitParams.AppSourceUri);
             if (commitParams.AppGroup != null)
             {
                 CheckInstalled(subState);
             }
             this.CheckApplicationPayload(commitParams);
         }
         bool      flag = false;
         bool      identityGroupFound       = false;
         bool      locationGroupFound       = false;
         string    identityGroupProductName = "";
         ArrayList list = this._compStore.CollectCrossGroupApplications(commitParams.DeploySourceUri, commitParams.DeployManifest.Identity, ref identityGroupFound, ref locationGroupFound, ref identityGroupProductName);
         if (list.Count > 0)
         {
             flag = true;
             Logger.AddInternalState("This installation is a Cross Group: identityGroupFound=" + identityGroupFound.ToString() + ",locationGroupFound=" + locationGroupFound.ToString());
         }
         if ((subState.IsShellVisible && identityGroupFound) && locationGroupFound)
         {
             throw new DeploymentException(ExceptionTypes.GroupMultipleMatch, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_GroupMultipleMatch"), new object[] { identityGroupProductName }));
         }
         subState = this.GetSubscriptionState(commitParams.DeployManifest);
         this._compStore.CommitApplication(subState, commitParams);
         if (flag)
         {
             uint num;
             Logger.AddInternalState("Performing cross group migration.");
             System.Deployment.Internal.Isolation.IActContext context = System.Deployment.Internal.Isolation.IsolationInterop.CreateActContext(subState.CurrentBind.ComPointer);
             context.PrepareForExecution(IntPtr.Zero, IntPtr.Zero);
             context.SetApplicationRunningState(0, 1, out num);
             context.SetApplicationRunningState(0, 2, out num);
             Logger.AddInternalState("Uninstalling all cross groups.");
             foreach (ComponentStore.CrossGroupApplicationData data in list)
             {
                 if (data.CrossGroupType == ComponentStore.CrossGroupApplicationData.GroupType.LocationGroup)
                 {
                     if (data.SubState.appType == AppType.CustomHostSpecified)
                     {
                         Logger.AddInternalState("UninstallCustomHostSpecifiedSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallCustomHostSpecifiedSubscription(data.SubState);
                     }
                     else if (data.SubState.appType == AppType.CustomUX)
                     {
                         Logger.AddInternalState("UninstallCustomUXSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallCustomUXSubscription(data.SubState);
                     }
                     else if (data.SubState.IsShellVisible)
                     {
                         Logger.AddInternalState("UninstallSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallSubscription(data.SubState);
                     }
                 }
                 else if (data.CrossGroupType == ComponentStore.CrossGroupApplicationData.GroupType.IdentityGroup)
                 {
                     Logger.AddInternalState("Not uninstalled :" + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null") + ". It is in the identity group.");
                 }
             }
         }
         if ((commitParams.IsConfirmed && subState.IsInstalled) && (subState.IsShellVisible && (commitParams.appType != AppType.CustomUX)))
         {
             this.UpdateSubscriptionExposure(subState);
         }
         if (commitParams.appType == AppType.CustomUX)
         {
             ShellExposure.ShellExposureInformation shellExposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
             ShellExposure.UpdateShellExtensions(subState, ref shellExposureInformation);
         }
         OnDeploymentAdded(subState);
     }
 }
            public static ShellExposure.ShellExposureInformation CreateShellExposureInformation(string publisher, string suiteName, string product, string shortcutAppId)
            {
                ShellExposure.ShellExposureInformation information = new ShellExposure.ShellExposureInformation();
                string str = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), publisher);
                string str2 = str;
                if (!string.IsNullOrEmpty(suiteName))
                {
                    str2 = Path.Combine(str, suiteName);
                }
                string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string str4 = null;
                string path = null;
                string str6 = null;
                int num = 0;
                num = 0;
            Label_003B:
                switch (num)
                {
                    case 0x7fffffff:
                        throw new OverflowException();

                    case 0:
                        str4 = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ShellExposure_DisplayStringNoIndex"), new object[] { product });
                        break;

                    default:
                        str4 = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ShellExposure_DisplayStringWithIndex"), new object[] { product, num });
                        break;
                }
                path = Path.Combine(str2, str4 + ".appref-ms");
                str6 = Path.Combine(folderPath, str4 + ".appref-ms");
                if (System.IO.File.Exists(path) || System.IO.File.Exists(str6))
                {
                    num++;
                    goto Label_003B;
                }
                information._appVendor = publisher;
                information._appProduct = str4;
                information._appSuiteName = suiteName;
                information._applicationFolderPath = str2;
                information._applicationRootFolderPath = str;
                information._applicationShortcutPath = path;
                information._desktopShortcutPath = str6;
                information._appSupportShortcut = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("SupportUrlFormatter"), new object[] { str4 });
                information._supportShortcutPath = Path.Combine(str2, information._appSupportShortcut + ".url");
                information._shortcutAppId = shortcutAppId;
                return information;
            }
 public static ShellExposure.ShellExposureInformation CreateShellExposureInformation(DefinitionIdentity subscriptionIdentity)
 {
     ShellExposure.ShellExposureInformation information = null;
     string str = null;
     string str2 = null;
     string str3 = null;
     string str4 = null;
     string str5 = "";
     using (RegistryKey key = ShellExposure.UninstallRoot.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
     {
         if (key != null)
         {
             using (RegistryKey key2 = key.OpenSubKey(ShellExposure.GenerateArpKeyName(subscriptionIdentity)))
             {
                 if (key2 != null)
                 {
                     str = key2.GetValue("ShortcutFolderName") as string;
                     str2 = key2.GetValue("ShortcutFileName") as string;
                     if (key2.GetValue("ShortcutSuiteName") != null)
                     {
                         str3 = key2.GetValue("ShortcutSuiteName") as string;
                     }
                     else
                     {
                         str3 = "";
                     }
                     str4 = key2.GetValue("SupportShortcutFileName") as string;
                     if (key2.GetValue("ShortcutAppId") != null)
                     {
                         str5 = key2.GetValue("ShortcutAppId") as string;
                     }
                     else
                     {
                         str5 = "";
                     }
                 }
             }
         }
     }
     if (((str != null) && (str2 != null)) && (str4 != null))
     {
         information = new ShellExposure.ShellExposureInformation {
             _applicationRootFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), str)
         };
         if (string.IsNullOrEmpty(str3))
         {
             information._applicationFolderPath = information._applicationRootFolderPath;
         }
         else
         {
             information._applicationFolderPath = Path.Combine(information._applicationRootFolderPath, str3);
         }
         information._applicationShortcutPath = Path.Combine(information._applicationFolderPath, str2 + ".appref-ms");
         information._supportShortcutPath = Path.Combine(information._applicationFolderPath, str4 + ".url");
         information._desktopShortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), str2 + ".appref-ms");
         information._appVendor = str;
         information._appProduct = str2;
         information._appSupportShortcut = str4;
         information._shortcutAppId = str5;
         information._appSuiteName = str3;
     }
     return information;
 }
Exemplo n.º 14
0
            public static ShellExposure.ShellExposureInformation CreateShellExposureInformation(DefinitionIdentity subscriptionIdentity)
            {
                ShellExposure.ShellExposureInformation information = null;
                string str  = null;
                string str2 = null;
                string str3 = null;
                string str4 = null;
                string str5 = "";

                using (RegistryKey key = ShellExposure.UninstallRoot.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
                {
                    if (key != null)
                    {
                        using (RegistryKey key2 = key.OpenSubKey(ShellExposure.GenerateArpKeyName(subscriptionIdentity)))
                        {
                            if (key2 != null)
                            {
                                str  = key2.GetValue("ShortcutFolderName") as string;
                                str2 = key2.GetValue("ShortcutFileName") as string;
                                if (key2.GetValue("ShortcutSuiteName") != null)
                                {
                                    str3 = key2.GetValue("ShortcutSuiteName") as string;
                                }
                                else
                                {
                                    str3 = "";
                                }
                                str4 = key2.GetValue("SupportShortcutFileName") as string;
                                if (key2.GetValue("ShortcutAppId") != null)
                                {
                                    str5 = key2.GetValue("ShortcutAppId") as string;
                                }
                                else
                                {
                                    str5 = "";
                                }
                            }
                        }
                    }
                }
                if (((str != null) && (str2 != null)) && (str4 != null))
                {
                    information = new ShellExposure.ShellExposureInformation {
                        _applicationRootFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), str)
                    };
                    if (string.IsNullOrEmpty(str3))
                    {
                        information._applicationFolderPath = information._applicationRootFolderPath;
                    }
                    else
                    {
                        information._applicationFolderPath = Path.Combine(information._applicationRootFolderPath, str3);
                    }
                    information._applicationShortcutPath = Path.Combine(information._applicationFolderPath, str2 + ".appref-ms");
                    information._supportShortcutPath     = Path.Combine(information._applicationFolderPath, str4 + ".url");
                    information._desktopShortcutPath     = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), str2 + ".appref-ms");
                    information._appVendor          = str;
                    information._appProduct         = str2;
                    information._appSupportShortcut = str4;
                    information._shortcutAppId      = str5;
                    information._appSuiteName       = str3;
                }
                return(information);
            }
Exemplo n.º 15
0
        private static void UpdateArpEntry(SubscriptionState subState, ShellExposure.ShellExposureInformation shellExposureInformation)
        {
            DefinitionIdentity subscriptionId = subState.SubscriptionId;
            string             str1           = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "rundll32.exe dfshim.dll,ShArpMaintain {0}", new object[1]
            {
                (object)subscriptionId.ToString()
            });
            string           str2 = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "dfshim.dll,2", new object[0]);
            AssemblyManifest deploymentManifest   = subState.CurrentDeploymentManifest;
            Description      effectiveDescription = subState.EffectiveDescription;

            using (RegistryKey subKey1 = ShellExposure.UninstallRoot.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"))
            {
                using (RegistryKey subKey2 = subKey1.CreateSubKey(ShellExposure.GenerateArpKeyName(subscriptionId)))
                {
                    string[] strArray = new string[24]
                    {
                        "DisplayName",
                        shellExposureInformation.ARPDisplayName,
                        "DisplayIcon",
                        str2,
                        "DisplayVersion",
                        deploymentManifest.Identity.Version.ToString(),
                        "Publisher",
                        effectiveDescription.FilteredPublisher,
                        "UninstallString",
                        str1,
                        "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.");
                    int index = strArray.Length - 2;
                    while (index >= 0)
                    {
                        string name = strArray[index];
                        string str3 = strArray[index + 1];
                        if (str3 != null)
                        {
                            subKey2.SetValue(name, (object)str3);
                        }
                        else
                        {
                            subKey2.DeleteValue(name, false);
                        }
                        index -= 2;
                    }
                }
            }
        }
Exemplo n.º 16
0
        private static void UpdateShortcuts(SubscriptionState subState, ref ShellExposure.ShellExposureInformation shellExposureInformation)
        {
            string      str = string.Format("{0}#{1}", (object)subState.DeploymentProviderUri.AbsoluteUri, (object)subState.SubscriptionId.ToString());
            Description effectiveDescription = subState.EffectiveDescription;

            if (shellExposureInformation != null)
            {
                bool flag1 = true;
                bool flag2 = true;
                bool flag3 = true;
                bool flag4 = true;
                if (string.Compare(effectiveDescription.FilteredPublisher, shellExposureInformation.AppVendor, StringComparison.Ordinal) == 0)
                {
                    flag1 = 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(str, shellExposureInformation.ShortcutAppId, StringComparison.Ordinal) == 0)
                            {
                                flag4 = false;
                            }
                        }
                    }
                }
                if (!flag1 && !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)
                {
                    ShellExposure.UnpinShortcut(shellExposureInformation.ApplicationShortcutPath);
                    ShellExposure.MoveDeleteFile(shellExposureInformation.ApplicationShortcutPath);
                    ShellExposure.MoveDeleteFile(shellExposureInformation.SupportShortcutPath);
                    ShellExposure.MoveDeleteFile(shellExposureInformation.DesktopShortcutPath);
                    Logger.AddInternalState("Shortcut files deleted:" + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath);
                }
                if (flag2)
                {
                    Logger.AddInternalState("Attempt deleting shortcut folder:" + shellExposureInformation.ApplicationFolderPath);
                    ShellExposure.MoveDeleteEmptyFolder(shellExposureInformation.ApplicationFolderPath);
                }
                if (flag1)
                {
                    Logger.AddInternalState("Attempt deleting shortcut root folder:" + shellExposureInformation.ApplicationRootFolderPath);
                    ShellExposure.MoveDeleteEmptyFolder(shellExposureInformation.ApplicationRootFolderPath);
                }
                if (flag1 | flag2 | flag3)
                {
                    shellExposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, str);
                }
                else
                {
                    Logger.AddInternalState("Shortcut app id has changed. Old value=" + shellExposureInformation.ShortcutAppId + ",New value=" + str);
                    shellExposureInformation.ShortcutAppId = str;
                }
            }
            else
            {
                shellExposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, str);
            }
            try
            {
                Logger.AddInternalState("Create the shortcut directory : " + shellExposureInformation.ApplicationFolderPath);
                Directory.CreateDirectory(shellExposureInformation.ApplicationFolderPath);
                ShellExposure.GenerateAppShortcut(subState, shellExposureInformation);
                ShellExposure.GenerateSupportShortcut(subState, shellExposureInformation);
            }
            catch (Exception ex)
            {
                ShellExposure.RemoveShortcuts(shellExposureInformation);
                throw;
            }
        }