Exemplo n.º 1
0
        /// <summary>
        /// Removes programs from disallow registry keys of specific user by account SID and program names executables
        /// </summary>
        /// <param name="AccountSID">Account SID for accessing registry</param>
        /// <param name="ProgramNames">Program names executables to exclude in restriction</param>
        public static void RemoveDisallowRegistryKeys(string AccountSID, string[] ProgramNames)
        {
            // Get Restriction key for removing restrictions
            RegistryKey RestrictionKey = GetRestrictionKey(AccountSID);

            // Removing each program from the restriction key
            foreach (string ProgramName in ProgramNames)
            {
                RestrictionKey.DeleteValue(ProgramName.Split('.')[0], false);
            }

            RestrictionKey.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds programs to disallow registry keys of specific user by account SID and program names executables
        /// </summary>
        /// <param name="AccountSID">Account SID for accessing registry</param>
        /// <param name="ProgramNames">Program names executables to include in restriction</param>
        public static void AddDisallowRegistryKeys(string AccountSID, string[] ProgramNames)
        {
            // Get Restriction key for adding restrictions
            RegistryKey RestrictionKey = GetRestrictionKey(AccountSID);

            // Adding each program to the restriction key
            foreach (string ProgramName in ProgramNames)
            {
                RestrictionKey.SetValue(ProgramName.Split('.')[0], ProgramName, RegistryValueKind.String);
            }

            RestrictionKey.Close();
        }