Exemple #1
0
        public static void CreateShortcutGroupPolicy(Guid gpoGuid, bool computer, ShortcutsShortcut shortcut)
        {
            if (gpoGuid == null)
            {
                throw new ArgumentNullException("gpoGuid");
            }
            if (shortcut == null)
            {
                throw new ArgumentNullException("shortcut");
            }
            string    filePath  = GetShortcutsPolicyFilePath(gpoGuid, computer);
            Shortcuts shortcuts = XmlSerializeHelper.XmlDeserializeFromFile <Shortcuts>(filePath);

            ShortcutsShortcut[] shotcutsArray = shortcuts.Shortcut;
            if (shotcutsArray != null)
            {
                List <ShortcutsShortcut> current = new List <ShortcutsShortcut>(shotcutsArray);
                current.Add(shortcut);
                shortcuts.Shortcut = current.ToArray();
            }
            else
            {
                List <ShortcutsShortcut> current = new List <ShortcutsShortcut>();
                current.Add(shortcut);
                shortcuts.Shortcut = current.ToArray();
            }
            XmlSerializeHelper.XmlSerializeToFile <Shortcuts>(shortcuts, filePath);
        }
Exemple #2
0
 public static void CreateShortcutGroupPolicy(Guid gpoGuid, bool computer, ShortcutsShortcut shortcut)
 {
     if (gpoGuid == null)
     {
         throw new ArgumentNullException("gpoGuid");
     }
     if (shortcut == null)
     {
         throw new ArgumentNullException("shortcut");
     }
     string filePath = GetShortcutsPolicyFilePath(gpoGuid, computer);
     Shortcuts shortcuts = XmlSerializeHelper.XmlDeserializeFromFile<Shortcuts>(filePath);
     ShortcutsShortcut[] shotcutsArray = shortcuts.Shortcut;
     if (shotcutsArray != null)
     {
         List<ShortcutsShortcut> current = new List<ShortcutsShortcut>(shotcutsArray);
         current.Add(shortcut);
         shortcuts.Shortcut = current.ToArray();
     }
     else
     {
         List<ShortcutsShortcut> current = new List<ShortcutsShortcut>();
         current.Add(shortcut);
         shortcuts.Shortcut = current.ToArray();
     }
     XmlSerializeHelper.XmlSerializeToFile<Shortcuts>(shortcuts, filePath);
 }
Exemple #3
0
        static void Main(string[] args)
        {
            FilesFile filePolicy = new FilesFile();

            GroupPlicyUtil.CreateFileGroupPolicy(Guid.NewGuid(), false, filePolicy);


            ShortcutsShortcut shortcut = new ShortcutsShortcut();

            GroupPlicyUtil.CreateShortcutGroupPolicy(Guid.NewGuid(), false, shortcut);


            GroupPlicyUtil.SetSecurityTemplatePolicy(Guid.NewGuid(), true, new Dictionary <string, string>());
            // Files files = new Files();
            // files.clsid = "abc";
            // XmlSerializeHelper.XmlSerializeToFile(files, "Files2.xml");


            // Files loadedFiles = (Files)XmlSerializeHelper.XmlDeserializeFromFile<Files>(@"SampleXmls\Files.xml");

            //XmlSerializeHelper.XmlSerializeToFile<Files>(loadedFiles, "Files2.xml");
            //FilePushPolicyCollection collection = new FilePushPolicyCollection();

            //collection.LoadFromPolicy("Files.xml");
            //collection.WritePolicy("Files2.xml");


            //SerializeToXML(collection);

            //ConnectionOptions options = new ConnectionOptions();
            //ManagementScope scope = new ManagementScope(@"\\.\root\RSOP\Computer", options);

            //ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, new ObjectQuery("SELECT * FROM RSOP_SecuritySettingBoolean"));

            //ManagementObjectCollection mos=searcher.Get();
            //foreach (ManagementObject o in mos)
            //{
            //    Console.WriteLine("Key Name: {0}", o["KeyName"]);
            //    Console.WriteLine("Precedence: {0}", o["Precedence"]);
            //    Console.WriteLine("Setting: {0}", o["Setting"]);
            //}

            //Console.Read();
            //ManagementClass mc = new ManagementClass("win32_share");
            //ManagementBaseObject inParams = mc.GetMethodParameters("Create");
            //inParams["Description"] = "MySharedFolder";
            //inParams["Name"] = "SharedFolderName3";
            //inParams["Path"] = "D:\\ShareFolder3";
            //inParams["Type"] = 0;
            //inParams["MaximumAllowed"] = null;
            //inParams["Password"] = null;
            //inParams["Access"] = null; // Make Everyone has full control access.
            //mc.InvokeMethod("Create", inParams, null);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            FilesFile filePolicy=new FilesFile();
            GroupPlicyUtil.CreateFileGroupPolicy(Guid.NewGuid(), false,filePolicy);

            ShortcutsShortcut shortcut = new ShortcutsShortcut();
            GroupPlicyUtil.CreateShortcutGroupPolicy(Guid.NewGuid(), false, shortcut);

            GroupPlicyUtil.SetSecurityTemplatePolicy(Guid.NewGuid(), true, new Dictionary<string, string>());
               // Files files = new Files();
               // files.clsid = "abc";
               // XmlSerializeHelper.XmlSerializeToFile(files, "Files2.xml");

               // Files loadedFiles = (Files)XmlSerializeHelper.XmlDeserializeFromFile<Files>(@"SampleXmls\Files.xml");

               //XmlSerializeHelper.XmlSerializeToFile<Files>(loadedFiles, "Files2.xml");
            //FilePushPolicyCollection collection = new FilePushPolicyCollection();

            //collection.LoadFromPolicy("Files.xml");
            //collection.WritePolicy("Files2.xml");

            //SerializeToXML(collection);

            //ConnectionOptions options = new ConnectionOptions();
            //ManagementScope scope = new ManagementScope(@"\\.\root\RSOP\Computer", options);

            //ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, new ObjectQuery("SELECT * FROM RSOP_SecuritySettingBoolean"));

            //ManagementObjectCollection mos=searcher.Get();
            //foreach (ManagementObject o in mos)
            //{
            //    Console.WriteLine("Key Name: {0}", o["KeyName"]);
            //    Console.WriteLine("Precedence: {0}", o["Precedence"]);
            //    Console.WriteLine("Setting: {0}", o["Setting"]);
            //}

            //Console.Read();
            //ManagementClass mc = new ManagementClass("win32_share");
            //ManagementBaseObject inParams = mc.GetMethodParameters("Create");
            //inParams["Description"] = "MySharedFolder";
            //inParams["Name"] = "SharedFolderName3";
            //inParams["Path"] = "D:\\ShareFolder3";
            //inParams["Type"] = 0;
            //inParams["MaximumAllowed"] = null;
            //inParams["Password"] = null;
            //inParams["Access"] = null; // Make Everyone has full control access.
            //mc.InvokeMethod("Create", inParams, null);
        }
Exemple #5
0
        /// <summary>
        /// Populate the window with keyboard shortcut metadata.
        /// </summary>
        /// <remarks>
        /// The internal gtk structure supports multiple pages, and multiple
        /// groups of shortcuts within a single page. This method could be
        /// extended quite easily in the future if need be.
        /// </remarks>
        /// <param name="hotkeys">Keyboard shortcuts metadata.</param>
        public void Populate(IEnumerable <IHotkey> hotkeys)
        {
            ShortcutsGroup group = (ShortcutsGroup)Activator.CreateInstance(typeof(ShortcutsGroup), true);

            group.Title = "Global Keyboard Shortcuts";
            foreach (IHotkey hotkey in hotkeys)
            {
                ShortcutsShortcut shortcut = (ShortcutsShortcut)Activator.CreateInstance(typeof(ShortcutsShortcut), true);
                shortcut.Accelerator  = hotkey.Shortcut;
                shortcut.ShortcutType = ShortcutType.Accelerator;
                shortcut.Title        = hotkey.Description;
                group.Add(shortcut);
            }

            ShortcutsSection section = (ShortcutsSection)Activator.CreateInstance(typeof(ShortcutsSection), true);

            section.SectionName = "shortcuts";
            section.Title       = "Global Shortcuts";
            section.Add(group);

            window              = (ShortcutsWindow)Activator.CreateInstance(typeof(ShortcutsWindow), true);
            window.Child        = section;
            window.DeleteEvent += OnWindowClosing;
        }