public RunAsAdministratorItem(ITsiAdministratorItem item) : base(AppString.Menu.RunAsAdministrator)
        {
            item.ContextMenuStrip.Opening += (sender, e) =>
            {
                if (item.ShellLink == null)
                {
                    this.Enabled = false;
                    return;
                }
                string filePath  = item.ShellLink.TargetPath;
                string extension = Path.GetExtension(filePath)?.ToLower();
                switch (extension)
                {
                case ".exe":
                case ".bat":
                case ".cmd":
                    this.Enabled = true;
                    break;

                default:
                    this.Enabled = false;
                    break;
                }
                this.Checked = item.ShellLink.RunAsAdministrator;
            };
            this.Click += (sender, e) =>
            {
                item.ShellLink.RunAsAdministrator = !this.Checked;
                item.ShellLink.Save();
                if (item is WinXItem)
                {
                    ExplorerRestarter.Show();
                }
            };
        }
예제 #2
0
 private void BlockGuid()
 {
     foreach (string path in GuidBlockedList.BlockedPaths)
     {
         if (TsiBlockGuid.Checked)
         {
             RegistryEx.DeleteValue(path, Item.Guid.ToString("B"));
         }
         else
         {
             Microsoft.Win32.Registry.SetValue(path, Item.Guid.ToString("B"), string.Empty);
         }
     }
     ExplorerRestarter.Show();
 }
 private void BlockGuid()
 {
     foreach (string path in GuidBlockedList.BlockedPaths)
     {
         if (TsiBlockGuid.Checked)
         {
             RegistryEx.DeleteValue(path, Item.Guid.ToString("B"));
         }
         else
         {
             if (Item.Guid.Equals(ShellExItem.LnkOpenGuid) && AppConfig.ProtectOpenItem)
             {
                 if (AppMessageBox.Show(AppString.Message.PromptIsOpenItem,
                                        MessageBoxButtons.YesNo) != DialogResult.Yes)
                 {
                     return;
                 }
             }
             Microsoft.Win32.Registry.SetValue(path, Item.Guid.ToString("B"), string.Empty);
         }
     }
     ExplorerRestarter.Show();
 }