Delete() public method

Delete the persistens registry file if it exists Throws Exception if something goes wrong
public Delete ( ) : void
return void
Esempio n. 1
0
        /// <summary>
        /// Resets the registry values if a PersistentRegistryFile is existing
        /// </summary>
        /// <returns></returns>
        public bool Reset()
        {
            bool res = true;

            try
            {
                using (var persistentRegistryFile = new PersistentRegistryFile())
                {
                    //Reset the registry values
                    res = this.SetRegistryEntries(persistentRegistryFile.FileContent.RegistryValues, persistentRegistryFile.FileContent.SID, persistentRegistryFile.FileContent.Username);
                    //Enable the windows Service if necessary
                    if (persistentRegistryFile.FileContent.EnableWindowsUpdate)
                    {
                        SetWindowsUpdate(true);
                    }

                    if (res)
                    {
                        persistentRegistryFile.Delete();
                    }
                }
            }
            catch (Exception)
            {
                res = false;
            }
            return(res);
        }
        /// <summary>
        /// Resets the registry values if a PersistentRegistryFile is existing
        /// </summary>
        /// <returns></returns>
        public bool Reset()
        {
            var success = true;

            try
            {
                Logger.Log("Attempting to reset registry values...");

                using (var persistentRegistryFile = new PersistentRegistryFile())
                {
                    if (persistentRegistryFile.FileContent.Username != null)
                    {
                        success = ResetRegistryEntries(persistentRegistryFile);

                        if (persistentRegistryFile.FileContent.EnableWindowsUpdate)
                        {
                            SetWindowsUpdate(true);
                        }

                        if (success)
                        {
                            persistentRegistryFile.Delete();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex, string.Format("Unable to reset registry values: {0} : {1}", ex.Message, ex.StackTrace));
                success = false;
            }

            return(success);
        }
Esempio n. 3
0
        /// <summary>
        /// Resets the registry values if a PersistentRegistryFile is existing
        /// </summary>
        /// <returns></returns>
        public bool Reset()
        {
            bool res = true;
            try
            {
                using (var persistentRegistryFile = new PersistentRegistryFile())
                {
                    //Reset the registry values
                    res = this.SetRegistryEntries(persistentRegistryFile.FileContent.RegistryValues, persistentRegistryFile.FileContent.Username);
                    //Enable the windows Service if necessary
                    if (persistentRegistryFile.FileContent.EnableWindowsUpdate)
                        SetWindowsUpdate(true);

                    if(res)
                        persistentRegistryFile.Delete();
                }
            }
            catch (Exception)
            {
                res = false;
            }
            return res;
        }