Browse Source

Smooth update 8.0. Pretty features.

deadmoon 4 years ago
parent
commit
99bc939a80

+ 6 - 0
CHANGELOG.md

@@ -2,6 +2,12 @@
 
 
 All notable changes to this project will be documented in this file.
 All notable changes to this project will be documented in this file.
 
 
+## [8.0] - 2021-05-30
+- New: Backup & restore Startup items
+- Improved: Performance tweaks
+- Improved: Better cconfiguration management
+- Hotfix: Detect missing apps download path
+
 ## [7.9] - 2021-05-27
 ## [7.9] - 2021-05-27
 - Hotfix: Issue #37, crashing when registry key permission is denied
 - Hotfix: Issue #37, crashing when registry key permission is denied
 
 

+ 2 - 2
Optimizer/Enums.cs

@@ -14,7 +14,7 @@
         Windows10
         Windows10
     }
     }
 
 
-    internal enum StartupItemLocation
+    public enum StartupItemLocation
     {
     {
         Folder,
         Folder,
         HKLM,
         HKLM,
@@ -22,7 +22,7 @@
         HKCU
         HKCU
     }
     }
 
 
-    internal enum StartupItemType
+    public enum StartupItemType
     {
     {
         None,
         None,
         Run,
         Run,

+ 118 - 0
Optimizer/MainForm.Designer.cs

@@ -316,6 +316,12 @@ namespace Optimizer
             this.exitItem = new System.Windows.Forms.ToolStripMenuItem();
             this.exitItem = new System.Windows.Forms.ToolStripMenuItem();
             this.launcherIcon = new System.Windows.Forms.NotifyIcon(this.components);
             this.launcherIcon = new System.Windows.Forms.NotifyIcon(this.components);
             this.infoTip = new System.Windows.Forms.ToolTip(this.components);
             this.infoTip = new System.Windows.Forms.ToolTip(this.components);
+            this.button11 = new System.Windows.Forms.Button();
+            this.button12 = new System.Windows.Forms.Button();
+            this.txtBackupTitle = new System.Windows.Forms.TextBox();
+            this.label4 = new System.Windows.Forms.Label();
+            this.button13 = new System.Windows.Forms.Button();
+            this.button14 = new System.Windows.Forms.Button();
             this.toggleSwitch38 = new Optimizer.ToggleSwitch();
             this.toggleSwitch38 = new Optimizer.ToggleSwitch();
             this.toggleSwitch36 = new Optimizer.ToggleSwitch();
             this.toggleSwitch36 = new Optimizer.ToggleSwitch();
             this.toggleSwitch33 = new Optimizer.ToggleSwitch();
             this.toggleSwitch33 = new Optimizer.ToggleSwitch();
@@ -996,6 +1002,12 @@ namespace Optimizer
             // startupTab
             // startupTab
             // 
             // 
             this.startupTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
             this.startupTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
+            this.startupTab.Controls.Add(this.button14);
+            this.startupTab.Controls.Add(this.button13);
+            this.startupTab.Controls.Add(this.txtBackupTitle);
+            this.startupTab.Controls.Add(this.label4);
+            this.startupTab.Controls.Add(this.button12);
+            this.startupTab.Controls.Add(this.button11);
             this.startupTab.Controls.Add(this.button64);
             this.startupTab.Controls.Add(this.button64);
             this.startupTab.Controls.Add(this.button31);
             this.startupTab.Controls.Add(this.button31);
             this.startupTab.Controls.Add(this.button37);
             this.startupTab.Controls.Add(this.button37);
@@ -4543,6 +4555,106 @@ namespace Optimizer
             this.infoTip.UseFading = false;
             this.infoTip.UseFading = false;
             this.infoTip.Popup += new System.Windows.Forms.PopupEventHandler(this.infoBaloon_Popup);
             this.infoTip.Popup += new System.Windows.Forms.PopupEventHandler(this.infoBaloon_Popup);
             // 
             // 
+            // button11
+            // 
+            this.button11.BackColor = System.Drawing.Color.DodgerBlue;
+            this.button11.FlatAppearance.BorderColor = System.Drawing.Color.DodgerBlue;
+            this.button11.FlatAppearance.MouseDownBackColor = System.Drawing.Color.RoyalBlue;
+            this.button11.FlatAppearance.MouseOverBackColor = System.Drawing.Color.RoyalBlue;
+            this.button11.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.button11.ForeColor = System.Drawing.Color.White;
+            this.button11.Location = new System.Drawing.Point(11, 563);
+            this.button11.Margin = new System.Windows.Forms.Padding(2);
+            this.button11.Name = "button11";
+            this.button11.Size = new System.Drawing.Size(101, 31);
+            this.button11.TabIndex = 41;
+            this.button11.Text = "Backup";
+            this.button11.UseVisualStyleBackColor = false;
+            this.button11.Click += new System.EventHandler(this.button11_Click);
+            // 
+            // button12
+            // 
+            this.button12.BackColor = System.Drawing.Color.DodgerBlue;
+            this.button12.FlatAppearance.BorderColor = System.Drawing.Color.DodgerBlue;
+            this.button12.FlatAppearance.MouseDownBackColor = System.Drawing.Color.RoyalBlue;
+            this.button12.FlatAppearance.MouseOverBackColor = System.Drawing.Color.RoyalBlue;
+            this.button12.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.button12.ForeColor = System.Drawing.Color.White;
+            this.button12.Location = new System.Drawing.Point(116, 563);
+            this.button12.Margin = new System.Windows.Forms.Padding(2);
+            this.button12.Name = "button12";
+            this.button12.Size = new System.Drawing.Size(101, 31);
+            this.button12.TabIndex = 42;
+            this.button12.Text = "Restore";
+            this.button12.UseVisualStyleBackColor = false;
+            this.button12.Click += new System.EventHandler(this.button12_Click);
+            // 
+            // txtBackupTitle
+            // 
+            this.txtBackupTitle.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
+            this.txtBackupTitle.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.txtBackupTitle.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.txtBackupTitle.ForeColor = System.Drawing.Color.White;
+            this.txtBackupTitle.Location = new System.Drawing.Point(114, 566);
+            this.txtBackupTitle.Margin = new System.Windows.Forms.Padding(2);
+            this.txtBackupTitle.Name = "txtBackupTitle";
+            this.txtBackupTitle.Size = new System.Drawing.Size(310, 29);
+            this.txtBackupTitle.TabIndex = 58;
+            this.txtBackupTitle.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+            this.txtBackupTitle.Visible = false;
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.label4.ForeColor = System.Drawing.Color.Silver;
+            this.label4.Location = new System.Drawing.Point(10, 569);
+            this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(100, 21);
+            this.label4.TabIndex = 59;
+            this.label4.Tag = "";
+            this.label4.Text = "Backup title:";
+            this.label4.Visible = false;
+            // 
+            // button13
+            // 
+            this.button13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.button13.BackColor = System.Drawing.Color.DodgerBlue;
+            this.button13.FlatAppearance.BorderColor = System.Drawing.Color.DodgerBlue;
+            this.button13.FlatAppearance.MouseDownBackColor = System.Drawing.Color.RoyalBlue;
+            this.button13.FlatAppearance.MouseOverBackColor = System.Drawing.Color.RoyalBlue;
+            this.button13.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.button13.ForeColor = System.Drawing.Color.White;
+            this.button13.Location = new System.Drawing.Point(430, 566);
+            this.button13.Margin = new System.Windows.Forms.Padding(2);
+            this.button13.Name = "button13";
+            this.button13.Size = new System.Drawing.Size(53, 29);
+            this.button13.TabIndex = 60;
+            this.button13.Text = "OK";
+            this.button13.UseVisualStyleBackColor = false;
+            this.button13.Visible = false;
+            this.button13.Click += new System.EventHandler(this.button13_Click);
+            // 
+            // button14
+            // 
+            this.button14.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.button14.BackColor = System.Drawing.Color.DodgerBlue;
+            this.button14.FlatAppearance.BorderColor = System.Drawing.Color.DodgerBlue;
+            this.button14.FlatAppearance.MouseDownBackColor = System.Drawing.Color.RoyalBlue;
+            this.button14.FlatAppearance.MouseOverBackColor = System.Drawing.Color.RoyalBlue;
+            this.button14.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.button14.ForeColor = System.Drawing.Color.White;
+            this.button14.Location = new System.Drawing.Point(487, 566);
+            this.button14.Margin = new System.Windows.Forms.Padding(2);
+            this.button14.Name = "button14";
+            this.button14.Size = new System.Drawing.Size(53, 29);
+            this.button14.TabIndex = 61;
+            this.button14.Text = "Cancel";
+            this.button14.UseVisualStyleBackColor = false;
+            this.button14.Visible = false;
+            this.button14.Click += new System.EventHandler(this.button14_Click);
+            // 
             // toggleSwitch38
             // toggleSwitch38
             // 
             // 
             this.toggleSwitch38.Location = new System.Drawing.Point(439, 89);
             this.toggleSwitch38.Location = new System.Drawing.Point(439, 89);
@@ -7182,6 +7294,12 @@ namespace Optimizer
         private System.Windows.Forms.Panel panel10;
         private System.Windows.Forms.Panel panel10;
         private ToolTip infoTip;
         private ToolTip infoTip;
         private ToggleSwitch helpTipsToggle;
         private ToggleSwitch helpTipsToggle;
+        private Button button11;
+        private Button button12;
+        private TextBox txtBackupTitle;
+        private Label label4;
+        private Button button13;
+        private Button button14;
     }
     }
 }
 }
 
 

+ 84 - 2
Optimizer/MainForm.cs

@@ -20,6 +20,8 @@ namespace Optimizer
         ListViewColumnSorter _columnSorter;
         ListViewColumnSorter _columnSorter;
 
 
         List<StartupItem> _startUpItems = new List<StartupItem>();
         List<StartupItem> _startUpItems = new List<StartupItem>();
+        List<StartupBackupItem> _backupItems = new List<StartupBackupItem>();
+
         List<string> _hostsEntries = new List<string>();
         List<string> _hostsEntries = new List<string>();
         List<string> _customCommands = new List<string>();
         List<string> _customCommands = new List<string>();
         List<string> _desktopItems = new List<string>();
         List<string> _desktopItems = new List<string>();
@@ -449,7 +451,15 @@ namespace Optimizer
             {
             {
                 if (!Directory.Exists(Options.CurrentOptions.AppsFolder))
                 if (!Directory.Exists(Options.CurrentOptions.AppsFolder))
                 {
                 {
-                    Directory.CreateDirectory(Options.CurrentOptions.AppsFolder);
+                    try
+                    {
+                        Directory.CreateDirectory(Options.CurrentOptions.AppsFolder);
+                    }
+                    catch (Exception ex)
+                    {
+                        txtDownloadFolder.Text = string.Empty;
+                        ErrorLogger.LogError("MainForm.INIT", ex.Message, ex.StackTrace);
+                    }
                 }
                 }
                 txtDownloadFolder.Text = Options.CurrentOptions.AppsFolder;
                 txtDownloadFolder.Text = Options.CurrentOptions.AppsFolder;
             }
             }
@@ -642,7 +652,7 @@ namespace Optimizer
 
 
         private void Main_Load(object sender, EventArgs e)
         private void Main_Load(object sender, EventArgs e)
         {
         {
-
+            
         }
         }
 
 
         private void GetDesktopItems()
         private void GetDesktopItems()
@@ -2556,5 +2566,77 @@ namespace Optimizer
 
 
             infoTip.Active = helpTipsToggle.Checked;
             infoTip.Active = helpTipsToggle.Checked;
         }
         }
+
+        private void button11_Click(object sender, EventArgs e)
+        {
+            ShowBackupConfirm();
+        }
+
+        private void ShowBackupConfirm()
+        {
+            button32.Visible = false;
+            button31.Visible = false;
+            button64.Visible = false;
+            button37.Visible = false;
+            button12.Visible = false;
+            button11.Visible = false;
+
+            label4.Visible = true;
+            button13.Visible = true;
+            button14.Visible = true;
+            txtBackupTitle.Visible = true;
+        }
+
+        private void HideBackupConfirm()
+        {
+            button32.Visible = true;
+            button31.Visible = true;
+            button64.Visible = true;
+            button37.Visible = true;
+            button12.Visible = true;
+            button11.Visible = true;
+
+            label4.Visible = false;
+            button13.Visible = false;
+            button14.Visible = false;
+            txtBackupTitle.Visible = false;
+        }
+
+        private void button12_Click(object sender, EventArgs e)
+        {
+            StartupRestoreForm f = new StartupRestoreForm();
+            f.ShowDialog(this);
+
+            GetStartupItems();
+        }
+
+        private void button14_Click(object sender, EventArgs e)
+        {
+            HideBackupConfirm();
+        }
+
+        private void button13_Click(object sender, EventArgs e)
+        {
+            if (!string.IsNullOrEmpty(txtBackupTitle.Text.Trim()))
+            {
+                HideBackupConfirm();
+
+                _backupItems.Clear();
+
+                foreach (var x in _startUpItems)
+                {
+                    _backupItems.Add(new StartupBackupItem(x.Name, x.FileLocation, x.RegistryLocation.ToString(), x.StartupType.ToString()));
+                }
+
+                try
+                {
+                    File.WriteAllText(Required.StartupItemsBackupFolder + Utilities.SanitizeFileFolderName(txtBackupTitle.Text + " - [" + DateTime.Now.ToShortDateString() + "-" + DateTime.Now.ToShortTimeString()) + "].json", JsonConvert.SerializeObject(_backupItems, Formatting.Indented));
+                }
+                catch (Exception ex)
+                {
+                    ErrorLogger.LogError("MainForm.BackupStartupItems", ex.Message, ex.StackTrace);
+                }
+            }
+        }
     }
     }
 }
 }

+ 14 - 0
Optimizer/Optimize.cs

@@ -88,6 +88,13 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "SystemResponsiveness", 1, RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "SystemResponsiveness", 1, RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", "GPU Priority", 8, RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", "GPU Priority", 8, RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", "Priority", 6, RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", "Priority", 6, RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", "Scheduling Category", "High", RegistryValueKind.String);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", "SFIO Priority", "High", RegistryValueKind.String);
+
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Low Latency", "GPU Priority", 0, RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Low Latency", "Priority", 8, RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Low Latency", "Scheduling Category", "Medium", RegistryValueKind.String);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Low Latency", "SFIO Priority", "High", RegistryValueKind.String);
         }
         }
 
 
         internal static void DisablePerformanceTweaks()
         internal static void DisablePerformanceTweaks()
@@ -131,6 +138,13 @@ namespace Optimizer
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "SystemResponsiveness", 14, RegistryValueKind.DWord);
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "SystemResponsiveness", 14, RegistryValueKind.DWord);
                 Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", true).DeleteValue("GPU Priority", false);
                 Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", true).DeleteValue("GPU Priority", false);
                 Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", true).DeleteValue("Priority", false);
                 Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", true).DeleteValue("Priority", false);
+                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", true).DeleteValue("Scheduling Category", false);
+                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", true).DeleteValue("SFIO Priority", false);
+
+                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Low Latency", true).DeleteValue("GPU Priority", false);
+                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Low Latency", true).DeleteValue("Priority", false);
+                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Low Latency", true).DeleteValue("Scheduling Category", false);
+                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Low Latency", true).DeleteValue("SFIO Priority", false);
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {

+ 20 - 1
Optimizer/Optimizer.csproj

@@ -13,6 +13,7 @@
     <FileAlignment>512</FileAlignment>
     <FileAlignment>512</FileAlignment>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <IsWebBootstrapper>false</IsWebBootstrapper>
     <IsWebBootstrapper>false</IsWebBootstrapper>
+    <TargetFrameworkProfile />
     <PublishUrl>publish\</PublishUrl>
     <PublishUrl>publish\</PublishUrl>
     <Install>true</Install>
     <Install>true</Install>
     <InstallFrom>Disk</InstallFrom>
     <InstallFrom>Disk</InstallFrom>
@@ -27,7 +28,6 @@
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
     <UseApplicationTrust>false</UseApplicationTrust>
     <UseApplicationTrust>false</UseApplicationTrust>
     <BootstrapperEnabled>true</BootstrapperEnabled>
     <BootstrapperEnabled>true</BootstrapperEnabled>
-    <TargetFrameworkProfile />
   </PropertyGroup>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -147,6 +147,19 @@
     <Compile Include="Required.cs" />
     <Compile Include="Required.cs" />
     <Compile Include="SilentConfig.cs" />
     <Compile Include="SilentConfig.cs" />
     <Compile Include="SilentOps.cs" />
     <Compile Include="SilentOps.cs" />
+    <Compile Include="StartupPreviewForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="StartupPreviewForm.Designer.cs">
+      <DependentUpon>StartupPreviewForm.cs</DependentUpon>
+    </Compile>
+    <Compile Include="StartupRestoreForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="StartupRestoreForm.Designer.cs">
+      <DependentUpon>StartupRestoreForm.cs</DependentUpon>
+    </Compile>
+    <Compile Include="StartupBackupItem.cs" />
     <Compile Include="StartupItem.cs" />
     <Compile Include="StartupItem.cs" />
     <Compile Include="ToggleSwitch\ImageHelper.cs" />
     <Compile Include="ToggleSwitch\ImageHelper.cs" />
     <Compile Include="ToggleSwitch\ToggleSwitch.cs">
     <Compile Include="ToggleSwitch\ToggleSwitch.cs">
@@ -183,6 +196,12 @@
     <EmbeddedResource Include="HelperForm.resx">
     <EmbeddedResource Include="HelperForm.resx">
       <DependentUpon>HelperForm.cs</DependentUpon>
       <DependentUpon>HelperForm.cs</DependentUpon>
     </EmbeddedResource>
     </EmbeddedResource>
+    <EmbeddedResource Include="StartupPreviewForm.resx">
+      <DependentUpon>StartupPreviewForm.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="StartupRestoreForm.resx">
+      <DependentUpon>StartupRestoreForm.cs</DependentUpon>
+    </EmbeddedResource>
     <None Include="app.manifest">
     <None Include="app.manifest">
       <SubType>Designer</SubType>
       <SubType>Designer</SubType>
     </None>
     </None>

+ 4 - 7
Optimizer/Program.cs

@@ -12,8 +12,8 @@ namespace Optimizer
 
 
         // Enter current version here
         // Enter current version here
 
 
-        internal readonly static float Major = 7;
-        internal readonly static float Minor = 9;
+        internal readonly static float Major = 8;
+        internal readonly static float Minor = 0;
 
 
         internal readonly static bool EXPERIMENTAL_BUILD = false;
         internal readonly static bool EXPERIMENTAL_BUILD = false;
 
 
@@ -46,7 +46,7 @@ namespace Optimizer
             AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
             AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
 
 
             // check if another instance is running
             // check if another instance is running
-            // problem? prevents auto-patching...
+            // what's the problem? prevents auto-patching...
 
 
             //if (System.Diagnostics.Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)).Length > 1)
             //if (System.Diagnostics.Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)).Length > 1)
             //{
             //{
@@ -68,10 +68,7 @@ namespace Optimizer
             {
             {
                 if (Utilities.IsCompatible())
                 if (Utilities.IsCompatible())
                 {
                 {
-                    if (!Directory.Exists(Required.CoreFolder))
-                    {
-                        Required.Deploy();
-                    }
+                    Required.Deploy();
 
 
                     // for backward compatibility (legacy)
                     // for backward compatibility (legacy)
                     if (File.Exists(Options.SettingsFile))
                     if (File.Exists(Options.SettingsFile))

+ 70 - 77
Optimizer/Required.cs

@@ -1,4 +1,6 @@
-using System.IO;
+using System;
+using System.IO;
+using System.Text;
 
 
 namespace Optimizer
 namespace Optimizer
 {
 {
@@ -9,6 +11,55 @@ namespace Optimizer
         internal readonly static string ScriptsFolder = CleanHelper.ProgramData + "\\Optimizer\\Required\\";
         internal readonly static string ScriptsFolder = CleanHelper.ProgramData + "\\Optimizer\\Required\\";
         internal readonly static string ExtractedIconsFolder = CleanHelper.ProgramData + "\\Optimizer\\ExtractedIcons\\";
         internal readonly static string ExtractedIconsFolder = CleanHelper.ProgramData + "\\Optimizer\\ExtractedIcons\\";
         internal readonly static string FavIconsFolder = CleanHelper.ProgramData + "\\Optimizer\\FavIcons\\";
         internal readonly static string FavIconsFolder = CleanHelper.ProgramData + "\\Optimizer\\FavIcons\\";
+        internal readonly static string StartupItemsBackupFolder = CleanHelper.ProgramData + "\\Optimizer\\StartupBackup\\";
+
+        readonly static string[] readyMadeMenusItems =
+        {
+            ReadyMadeMenusFolder + "DesktopShortcuts.reg",
+            ReadyMadeMenusFolder + "SystemShortcuts.reg",
+            ReadyMadeMenusFolder + "PowerMenu.reg",
+            ReadyMadeMenusFolder + "SystemTools.reg",
+            ReadyMadeMenusFolder + "WindowsApps.reg",
+            ReadyMadeMenusFolder + "InstallTakeOwnership.reg",
+            ReadyMadeMenusFolder + "RemoveTakeOwnership.reg"
+        };
+
+        readonly static string[] readyMadeMenusFiles =
+        {
+            Properties.Resources.DesktopShortcuts,
+            Properties.Resources.SystemShortcuts,
+            Properties.Resources.PowerMenu,
+            Properties.Resources.SystemTools,
+            Properties.Resources.WindowsApps,
+            Properties.Resources.InstallTakeOwnership,
+            Properties.Resources.RemoveTakeOwnership
+        };
+
+        readonly static string[] scriptItems =
+        {
+            ScriptsFolder + "DisableOfficeTelemetryTasks.bat",
+            ScriptsFolder + "DisableOfficeTelemetryTasks.reg",
+            ScriptsFolder + "EnableOfficeTelemetryTasks.bat",
+            ScriptsFolder + "EnableOfficeTelemetryTasks.reg",
+            ScriptsFolder + "DisableTelemetryTasks.bat",
+            ScriptsFolder + "EnableTelemetryTasks.bat",
+            ScriptsFolder + "DisableXboxTasks.bat",
+            ScriptsFolder + "EnableXboxTasks.bat",
+            ScriptsFolder + "OneDrive_Uninstaller.cmd"
+        };
+
+        readonly static string[] scriptFiles =
+        {
+            Properties.Resources.DisableOfficeTelemetryTasks,
+            Properties.Resources.DisableOfficeTelemetry,
+            Properties.Resources.EnableOfficeTelemetryTasks,
+            Properties.Resources.EnableOfficeTelemetry,
+            Properties.Resources.DisableTelemetryTasks,
+            Properties.Resources.EnableTelemetryTasks,
+            Properties.Resources.DisableXboxTasks,
+            Properties.Resources.EnableXboxTasks,
+            Encoding.UTF8.GetString(Properties.Resources.OneDrive_Uninstaller)
+        };
 
 
         internal static void Deploy()
         internal static void Deploy()
         {
         {
@@ -32,88 +83,30 @@ namespace Optimizer
             {
             {
                 Directory.CreateDirectory(FavIconsFolder);
                 Directory.CreateDirectory(FavIconsFolder);
             }
             }
-
-            try
+            if (!Directory.Exists(StartupItemsBackupFolder))
             {
             {
-                File.WriteAllText(ReadyMadeMenusFolder + "DesktopShortcuts.reg", Properties.Resources.DesktopShortcuts);
+                Directory.CreateDirectory(StartupItemsBackupFolder);
             }
             }
-            catch { }
-            try
-            {
-                File.WriteAllText(ReadyMadeMenusFolder + "SystemShortcuts.reg", Properties.Resources.SystemShortcuts);
-            }
-            catch { }
-            try
-            {
-                File.WriteAllText(ReadyMadeMenusFolder + "PowerMenu.reg", Properties.Resources.PowerMenu);
-            }
-            catch { }
-            try
-            {
-                File.WriteAllText(ReadyMadeMenusFolder + "SystemTools.reg", Properties.Resources.SystemTools);
-            }
-            catch { }
-            try
-            {
-                File.WriteAllText(ReadyMadeMenusFolder + "WindowsApps.reg", Properties.Resources.WindowsApps);
-            }
-            catch { }
 
 
-            try
-            {
-                File.WriteAllText(ScriptsFolder + "DisableOfficeTelemetryTasks.bat", Properties.Resources.DisableOfficeTelemetryTasks);
-            }
-            catch { }
-            try
+            for (int i = 0; i < readyMadeMenusItems.Length; i++)
             {
             {
-                File.WriteAllText(ScriptsFolder + "DisableOfficeTelemetryTasks.reg", Properties.Resources.DisableOfficeTelemetry);
+                if (!File.Exists(readyMadeMenusItems[i])) File.WriteAllText(readyMadeMenusItems[i], readyMadeMenusFiles[i]);
             }
             }
-            catch { }
-            try
-            {
-                File.WriteAllText(ScriptsFolder + "EnableOfficeTelemetryTasks.bat", Properties.Resources.EnableOfficeTelemetryTasks);
-            }
-            catch { }
-            try
-            {
-                File.WriteAllText(ScriptsFolder + "EnableOfficeTelemetryTasks.reg", Properties.Resources.EnableOfficeTelemetry);
-            }
-            catch { }
-            try
-            {
-                File.WriteAllText(ScriptsFolder + "DisableTelemetryTasks.bat", Properties.Resources.DisableTelemetryTasks);
-            }
-            catch { }
-            try
-            {
-                File.WriteAllText(ScriptsFolder + "EnableTelemetryTasks.bat", Properties.Resources.EnableTelemetryTasks);
-            }
-            catch { }
-            try
-            {
-                File.WriteAllText(ScriptsFolder + "DisableXboxTasks.bat", Properties.Resources.DisableXboxTasks);
-            }
-            catch { }
-            try
-            {
-                File.WriteAllText(ScriptsFolder + "EnableXboxTasks.bat", Properties.Resources.EnableXboxTasks);
-            }
-            catch { }
-            try
-            {
-                File.WriteAllBytes(ScriptsFolder + "OneDrive_Uninstaller.cmd", Properties.Resources.OneDrive_Uninstaller);
-            }
-            catch { }
-            try
-            {
-                File.WriteAllText(ReadyMadeMenusFolder + "InstallTakeOwnership.reg", Properties.Resources.InstallTakeOwnership);
-            }
-            catch { }
-            try
-            {
-                File.WriteAllText(ReadyMadeMenusFolder + "RemoveTakeOwnership.reg", Properties.Resources.RemoveTakeOwnership);
+
+            for (int i = 0; i < scriptItems.Length; i++)
+            {
+                if (!File.Exists(scriptItems[i]))
+                {
+                    if (scriptItems[i].Contains("OneDrive"))
+                    {
+                        File.WriteAllBytes(scriptItems[i], Encoding.UTF8.GetBytes(scriptFiles[i]));
+                    }
+                    else
+                    {
+                        File.WriteAllText(scriptItems[i], scriptFiles[i]);
+                    }
+                }
             }
             }
-            catch { }
         }
         }
 
 
         internal static void Clean()
         internal static void Clean()

+ 25 - 0
Optimizer/StartupBackupItem.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Optimizer
+{
+    [Serializable]
+    public class StartupBackupItem
+    {
+        public string Name { get; set; }
+        public string FileLocation { get; set; }
+        public string RegistryLocation { get; set; }
+        public string StartupType { get; set; }
+
+        public StartupBackupItem(string n, string fl, string rl, string st)
+        {
+            Name = n;
+            FileLocation = fl;
+            RegistryLocation = rl;
+            StartupType = st;
+        }
+    }
+}

+ 90 - 0
Optimizer/StartupPreviewForm.Designer.cs

@@ -0,0 +1,90 @@
+namespace Optimizer
+{
+    partial class StartupPreviewForm
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.panel1 = new System.Windows.Forms.Panel();
+            this.listPreview = new System.Windows.Forms.ListBox();
+            this.panel1.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // panel1
+            // 
+            this.panel1.Controls.Add(this.listPreview);
+            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.panel1.Location = new System.Drawing.Point(0, 0);
+            this.panel1.Name = "panel1";
+            this.panel1.Size = new System.Drawing.Size(686, 214);
+            this.panel1.TabIndex = 0;
+            // 
+            // listPreview
+            // 
+            this.listPreview.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
+            this.listPreview.BorderStyle = System.Windows.Forms.BorderStyle.None;
+            this.listPreview.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.listPreview.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.listPreview.ForeColor = System.Drawing.Color.White;
+            this.listPreview.FormattingEnabled = true;
+            this.listPreview.HorizontalScrollbar = true;
+            this.listPreview.ItemHeight = 21;
+            this.listPreview.Location = new System.Drawing.Point(0, 0);
+            this.listPreview.Name = "listPreview";
+            this.listPreview.SelectionMode = System.Windows.Forms.SelectionMode.None;
+            this.listPreview.Size = new System.Drawing.Size(686, 214);
+            this.listPreview.TabIndex = 0;
+            // 
+            // StartupPreviewForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
+            this.ClientSize = new System.Drawing.Size(686, 214);
+            this.Controls.Add(this.panel1);
+            this.DoubleBuffered = true;
+            this.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.ForeColor = System.Drawing.Color.White;
+            this.MaximizeBox = false;
+            this.MinimizeBox = false;
+            this.Name = "StartupPreviewForm";
+            this.ShowIcon = false;
+            this.ShowInTaskbar = false;
+            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+            this.Text = "Startup Items Preview";
+            this.Load += new System.EventHandler(this.StartupPreviewForm_Load);
+            this.panel1.ResumeLayout(false);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Panel panel1;
+        private System.Windows.Forms.ListBox listPreview;
+    }
+}

+ 62 - 0
Optimizer/StartupPreviewForm.cs

@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Optimizer
+{
+    public partial class StartupPreviewForm : Form
+    {
+        string _token = string.Empty;
+
+        public StartupPreviewForm(List<StartupBackupItem> items)
+        {
+            InitializeComponent();
+
+            CheckForIllegalCrossThreadCalls = false;
+            Options.ApplyTheme(this);
+
+            foreach (StartupBackupItem x in items)
+            {
+                if (File.Exists(SanitizePath(x.FileLocation)))
+                {
+                    _token = "[✓] ";
+                }
+                else
+                {
+                    _token = "[⚠] ";
+                }
+
+                listPreview.Items.Add(_token + x.Name + " - " + x.FileLocation);
+            }    
+        }
+
+        private void StartupPreviewForm_Load(object sender, EventArgs e)
+        {
+            this.Focus();
+        }
+
+        private string SanitizePath(string s)
+        {
+            s = s.Replace("\"", string.Empty);
+            int i;
+
+            while (s.Contains("/"))
+            {
+                i = s.LastIndexOf("/");
+                s = s.Substring(0, i);
+            }
+
+            i = s.IndexOf(".exe");
+            s = s.Substring(0, i + 4);
+
+            return s.Trim();
+        }
+    }
+}

+ 123 - 0
Optimizer/StartupPreviewForm.resx

@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="listPreview.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+</root>

+ 187 - 0
Optimizer/StartupRestoreForm.Designer.cs

@@ -0,0 +1,187 @@
+namespace Optimizer
+{
+    partial class StartupRestoreForm
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.label5 = new System.Windows.Forms.Label();
+            this.listRestoreItems = new System.Windows.Forms.ListBox();
+            this.panel1 = new System.Windows.Forms.Panel();
+            this.button39 = new System.Windows.Forms.Button();
+            this.button1 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
+            this.txtNoBackups = new System.Windows.Forms.Label();
+            this.panel1.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Font = new System.Drawing.Font("Segoe UI Semibold", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.label5.ForeColor = System.Drawing.Color.DodgerBlue;
+            this.label5.Location = new System.Drawing.Point(7, 9);
+            this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(254, 28);
+            this.label5.TabIndex = 4;
+            this.label5.Tag = "themeable";
+            this.label5.Text = "Restore your startup items";
+            // 
+            // listRestoreItems
+            // 
+            this.listRestoreItems.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
+            this.listRestoreItems.BorderStyle = System.Windows.Forms.BorderStyle.None;
+            this.listRestoreItems.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.listRestoreItems.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.listRestoreItems.ForeColor = System.Drawing.Color.White;
+            this.listRestoreItems.FormattingEnabled = true;
+            this.listRestoreItems.ItemHeight = 21;
+            this.listRestoreItems.Location = new System.Drawing.Point(0, 0);
+            this.listRestoreItems.Name = "listRestoreItems";
+            this.listRestoreItems.Size = new System.Drawing.Size(404, 383);
+            this.listRestoreItems.TabIndex = 5;
+            this.listRestoreItems.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listRestoreItems_MouseDoubleClick);
+            // 
+            // panel1
+            // 
+            this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left)));
+            this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.panel1.Controls.Add(this.txtNoBackups);
+            this.panel1.Controls.Add(this.listRestoreItems);
+            this.panel1.Location = new System.Drawing.Point(12, 50);
+            this.panel1.Name = "panel1";
+            this.panel1.Size = new System.Drawing.Size(406, 385);
+            this.panel1.TabIndex = 6;
+            // 
+            // button39
+            // 
+            this.button39.BackColor = System.Drawing.Color.DodgerBlue;
+            this.button39.FlatAppearance.BorderColor = System.Drawing.Color.DodgerBlue;
+            this.button39.FlatAppearance.MouseDownBackColor = System.Drawing.Color.RoyalBlue;
+            this.button39.FlatAppearance.MouseOverBackColor = System.Drawing.Color.RoyalBlue;
+            this.button39.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.button39.ForeColor = System.Drawing.Color.White;
+            this.button39.Location = new System.Drawing.Point(423, 50);
+            this.button39.Margin = new System.Windows.Forms.Padding(2);
+            this.button39.Name = "button39";
+            this.button39.Size = new System.Drawing.Size(102, 31);
+            this.button39.TabIndex = 31;
+            this.button39.Text = "Preview";
+            this.button39.UseVisualStyleBackColor = false;
+            this.button39.Click += new System.EventHandler(this.button39_Click);
+            // 
+            // button1
+            // 
+            this.button1.BackColor = System.Drawing.Color.DodgerBlue;
+            this.button1.FlatAppearance.BorderColor = System.Drawing.Color.DodgerBlue;
+            this.button1.FlatAppearance.MouseDownBackColor = System.Drawing.Color.RoyalBlue;
+            this.button1.FlatAppearance.MouseOverBackColor = System.Drawing.Color.RoyalBlue;
+            this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.button1.ForeColor = System.Drawing.Color.White;
+            this.button1.Location = new System.Drawing.Point(423, 85);
+            this.button1.Margin = new System.Windows.Forms.Padding(2);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(102, 31);
+            this.button1.TabIndex = 32;
+            this.button1.Text = "Restore";
+            this.button1.UseVisualStyleBackColor = false;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // button2
+            // 
+            this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+            this.button2.BackColor = System.Drawing.Color.DodgerBlue;
+            this.button2.FlatAppearance.BorderColor = System.Drawing.Color.DodgerBlue;
+            this.button2.FlatAppearance.MouseDownBackColor = System.Drawing.Color.RoyalBlue;
+            this.button2.FlatAppearance.MouseOverBackColor = System.Drawing.Color.RoyalBlue;
+            this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.button2.ForeColor = System.Drawing.Color.White;
+            this.button2.Location = new System.Drawing.Point(423, 404);
+            this.button2.Margin = new System.Windows.Forms.Padding(2);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(102, 31);
+            this.button2.TabIndex = 33;
+            this.button2.Text = "Delete";
+            this.button2.UseVisualStyleBackColor = false;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // txtNoBackups
+            // 
+            this.txtNoBackups.BackColor = System.Drawing.Color.Transparent;
+            this.txtNoBackups.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.txtNoBackups.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.txtNoBackups.ForeColor = System.Drawing.Color.Gold;
+            this.txtNoBackups.Location = new System.Drawing.Point(0, 0);
+            this.txtNoBackups.Name = "txtNoBackups";
+            this.txtNoBackups.Size = new System.Drawing.Size(404, 383);
+            this.txtNoBackups.TabIndex = 168;
+            this.txtNoBackups.Text = "No backups found";
+            this.txtNoBackups.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+            this.txtNoBackups.Visible = false;
+            // 
+            // StartupRestoreForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
+            this.ClientSize = new System.Drawing.Size(536, 447);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.button1);
+            this.Controls.Add(this.button39);
+            this.Controls.Add(this.panel1);
+            this.Controls.Add(this.label5);
+            this.DoubleBuffered = true;
+            this.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.ForeColor = System.Drawing.Color.White;
+            this.MaximizeBox = false;
+            this.MinimizeBox = false;
+            this.MinimumSize = new System.Drawing.Size(552, 486);
+            this.Name = "StartupRestoreForm";
+            this.ShowIcon = false;
+            this.ShowInTaskbar = false;
+            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+            this.Text = "Restore Startup Items";
+            this.Load += new System.EventHandler(this.StartupRestoreForm_Load);
+            this.panel1.ResumeLayout(false);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.ListBox listRestoreItems;
+        private System.Windows.Forms.Panel panel1;
+        private System.Windows.Forms.Button button39;
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Button button2;
+        private System.Windows.Forms.Label txtNoBackups;
+    }
+}

+ 161 - 0
Optimizer/StartupRestoreForm.cs

@@ -0,0 +1,161 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.IO;
+using Microsoft.Win32;
+using Newtonsoft.Json;
+
+namespace Optimizer
+{
+    public partial class StartupRestoreForm : Form
+    {
+        string[] _backups;
+
+        public StartupRestoreForm()
+        {
+            InitializeComponent();
+
+            CheckForIllegalCrossThreadCalls = false;
+            Options.ApplyTheme(this);
+
+            RefreshBackups();
+        }
+
+        private void RefreshBackups()
+        {
+            _backups = Directory.GetFiles(Required.StartupItemsBackupFolder, "*.json");
+            Array.Reverse(_backups);
+            listRestoreItems.Items.Clear();
+
+            txtNoBackups.Visible = _backups.Length == 0;
+
+            foreach (string x in _backups)
+            {
+                listRestoreItems.Items.Add(Path.GetFileNameWithoutExtension(x));
+            }
+        }
+
+        private void StartupRestoreForm_Load(object sender, EventArgs e)
+        {
+            
+        }
+
+        // DeleteStartupBackup
+        private void button2_Click(object sender, EventArgs e)
+        {
+            if (listRestoreItems.SelectedIndex > -1)
+            {
+                if (MessageBox.Show("Do you really want to delete this backup?", "Delete Backup?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+                {
+                    try
+                    {
+                        File.Delete(_backups[listRestoreItems.SelectedIndex]);
+                    }
+                    catch (Exception ex)
+                    {
+                        ErrorLogger.LogError("StartupRestoreForm.DeleteStartupBackup", ex.Message, ex.StackTrace);
+                    }
+
+                    RefreshBackups();
+                }
+            }
+        }
+
+        private void ShowPreview()
+        {
+            if (listRestoreItems.SelectedIndex > -1)
+            {
+                List<StartupBackupItem> backup = JsonConvert.DeserializeObject<List<StartupBackupItem>>(File.ReadAllText(_backups[listRestoreItems.SelectedIndex]));
+                StartupPreviewForm f = new StartupPreviewForm(backup);
+                f.ShowDialog(this);
+            }
+        }
+
+        private void button39_Click(object sender, EventArgs e)
+        {
+            ShowPreview();
+        }
+
+        private void listRestoreItems_MouseDoubleClick(object sender, MouseEventArgs e)
+        {
+            ShowPreview();
+        }
+
+        // RestoreStartupBackup
+        private void button1_Click(object sender, EventArgs e)
+        {
+            if (listRestoreItems.SelectedIndex > -1)
+            {
+                List<StartupBackupItem> backup = JsonConvert.DeserializeObject<List<StartupBackupItem>>(File.ReadAllText(_backups[listRestoreItems.SelectedIndex]));
+
+                string keyPath = string.Empty;
+                RegistryKey hive = null;
+
+                foreach (StartupBackupItem x in backup)
+                {
+                    if (x.RegistryLocation == StartupItemLocation.HKLM.ToString())
+                    {
+                        hive = Registry.LocalMachine;
+
+                        if (x.StartupType == StartupItemType.Run.ToString())
+                        {
+                            keyPath = Utilities.LocalMachineRun;
+                        }
+                        else if (x.StartupType == StartupItemType.RunOnce.ToString())
+                        {
+                            keyPath = Utilities.LocalMachineRunOnce;
+                        }
+                    }
+                    else if (x.RegistryLocation == StartupItemLocation.HKLMWoW.ToString())
+                    {
+                        hive = Registry.LocalMachine;
+
+                        if (x.StartupType == StartupItemType.Run.ToString())
+                        {
+                            keyPath = Utilities.LocalMachineRunWoW;
+                        }
+                        else if (x.StartupType == StartupItemType.RunOnce.ToString())
+                        {
+                            keyPath = Utilities.LocalMachineRunOnceWow;
+                        }
+                    }
+                    else if (x.RegistryLocation == StartupItemLocation.HKCU.ToString())
+                    {
+                        hive = Registry.CurrentUser;
+
+                        if (x.StartupType == StartupItemType.Run.ToString())
+                        {
+                            keyPath = Utilities.CurrentUserRun;
+                        }
+                        else if (x.StartupType == StartupItemType.RunOnce.ToString())
+                        {
+                            keyPath = Utilities.CurrentUserRunOnce;
+                        }
+                    }
+
+                    if (hive != null)
+                    {
+                        try
+                        {
+                            RegistryKey key = hive.OpenSubKey(keyPath, true);
+                            key.SetValue(x.Name, x.FileLocation, RegistryValueKind.String);
+                            
+                        }
+                        catch (Exception ex)
+                        {
+                            ErrorLogger.LogError("StartupRestoreForm.RestoreStartupBackup", ex.Message, ex.StackTrace);
+                        }
+                    }
+                }
+
+                this.Close();
+            }
+        }
+    }
+}

+ 120 - 0
Optimizer/StartupRestoreForm.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 5 - 0
Optimizer/ToggleSwitch/ToggleSwitchRenderer.cs

@@ -50,6 +50,11 @@ namespace Optimizer
                     LeftSideColorHovered = Color.MediumOrchid;
                     LeftSideColorHovered = Color.MediumOrchid;
                     LeftSideColorPressed = Color.MediumOrchid;
                     LeftSideColorPressed = Color.MediumOrchid;
                     break;
                     break;
+                default:
+                    LeftSideColor = Color.MediumOrchid;
+                    LeftSideColorHovered = Color.MediumOrchid;
+                    LeftSideColorPressed = Color.MediumOrchid;
+                    break;
             }
             }
 
 
             BorderColor = Color.FromArgb(20, 20, 20);
             BorderColor = Color.FromArgb(20, 20, 20);

+ 6 - 0
Optimizer/Utilities.cs

@@ -662,5 +662,11 @@ namespace Optimizer
         {
         {
             Utilities.RunCommand("ipconfig /release && ipconfig /flushdns && ipconfig /renew");
             Utilities.RunCommand("ipconfig /release && ipconfig /flushdns && ipconfig /renew");
         }
         }
+
+        internal static string SanitizeFileFolderName(string fileName)
+        {
+            char[] invalids = Path.GetInvalidFileNameChars();
+            return string.Join("_", fileName.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.');
+        }
     }
     }
 }
 }

+ 3 - 3
README.md

@@ -54,6 +54,6 @@ https://github.com/hellzerg/optimizer/blob/master/LEGACY.md
 
 
 ## Details: ##
 ## Details: ##
 
 
-* Latest version: 7.9
-* Released: May 27, 2021
-* SHA256: 81BC6B676B1D9C6625233D2045CC18771E57E6AA570F2FF8CCE2A88784E1636B
+* Latest version: 8.0
+* Released: May 30, 2021
+* SHA256: 5067D78B430708A45601CD4DC3618C645BECF99CF442A79A8BC4033D6E88D07A

+ 1 - 1
version.txt

@@ -1 +1 @@
-7.9
+8.0