deadmoon 3 年之前
父节点
当前提交
43253f0994

+ 3 - 20
Optimizer/Forms/MainForm.Designer.cs

@@ -107,7 +107,6 @@ namespace Optimizer
             this.modernAppsTab = new System.Windows.Forms.TabPage();
             this.chkOnlyRemovable = new Optimizer.MoonCheck();
             this.chkSelectAllModernApps = new Optimizer.MoonCheck();
-            this.txtUWP = new System.Windows.Forms.Label();
             this.uninstallModernAppsButton = new System.Windows.Forms.Button();
             this.refreshModernAppsButton = new System.Windows.Forms.Button();
             this.txtModernAppsTitle = new System.Windows.Forms.Label();
@@ -1430,7 +1429,6 @@ namespace Optimizer
             this.modernAppsTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
             this.modernAppsTab.Controls.Add(this.chkOnlyRemovable);
             this.modernAppsTab.Controls.Add(this.chkSelectAllModernApps);
-            this.modernAppsTab.Controls.Add(this.txtUWP);
             this.modernAppsTab.Controls.Add(this.uninstallModernAppsButton);
             this.modernAppsTab.Controls.Add(this.refreshModernAppsButton);
             this.modernAppsTab.Controls.Add(this.txtModernAppsTitle);
@@ -1469,20 +1467,6 @@ namespace Optimizer
             this.chkSelectAllModernApps.Text = "Select all";
             this.chkSelectAllModernApps.UseVisualStyleBackColor = true;
             this.chkSelectAllModernApps.CheckedChanged += new System.EventHandler(this.chkSelectAllModernApps_CheckedChanged);
-            // 
-            // txtUWP
-            // 
-            this.txtUWP.AutoSize = true;
-            this.txtUWP.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            this.txtUWP.ForeColor = System.Drawing.Color.Silver;
-            this.txtUWP.Location = new System.Drawing.Point(499, 195);
-            this.txtUWP.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
-            this.txtUWP.Name = "txtUWP";
-            this.txtUWP.Size = new System.Drawing.Size(160, 231);
-            this.txtUWP.TabIndex = 51;
-            this.txtUWP.Tag = "";
-            this.txtUWP.Text = "IMPORTANT:\r\n\r\nIf you uninstall Store\r\nyou won\'t be able\r\nto install new apps!\r\n\r\n" +
-    "Also, some apps\r\ncan\'t be uninstalled.\r\n\r\nLike Microsoft Edge,\r\nSettings, etc.";
             // 
             // uninstallModernAppsButton
             // 
@@ -3887,7 +3871,7 @@ namespace Optimizer
             this.tabPage8.Margin = new System.Windows.Forms.Padding(2);
             this.tabPage8.Name = "tabPage8";
             this.tabPage8.Padding = new System.Windows.Forms.Padding(2);
-            this.tabPage8.Size = new System.Drawing.Size(987, 578);
+            this.tabPage8.Size = new System.Drawing.Size(987, 577);
             this.tabPage8.TabIndex = 1;
             this.tabPage8.Text = "Add/Modify";
             // 
@@ -4231,7 +4215,7 @@ namespace Optimizer
             this.tabPage9.Margin = new System.Windows.Forms.Padding(2);
             this.tabPage9.Name = "tabPage9";
             this.tabPage9.Padding = new System.Windows.Forms.Padding(2);
-            this.tabPage9.Size = new System.Drawing.Size(987, 578);
+            this.tabPage9.Size = new System.Drawing.Size(987, 577);
             this.tabPage9.TabIndex = 2;
             this.tabPage9.Text = "Remove";
             // 
@@ -4481,7 +4465,7 @@ namespace Optimizer
             this.tabPage11.Margin = new System.Windows.Forms.Padding(2);
             this.tabPage11.Name = "tabPage11";
             this.tabPage11.Padding = new System.Windows.Forms.Padding(2);
-            this.tabPage11.Size = new System.Drawing.Size(987, 578);
+            this.tabPage11.Size = new System.Drawing.Size(987, 577);
             this.tabPage11.TabIndex = 4;
             this.tabPage11.Text = "Run Dialog";
             // 
@@ -5655,7 +5639,6 @@ namespace Optimizer
         private MoonCheckList listModernApps;
         private System.Windows.Forms.Button uninstallModernAppsButton;
         private System.Windows.Forms.Button refreshModernAppsButton;
-        private System.Windows.Forms.Label txtUWP;
         private MoonCheck chkSelectAllModernApps;
         private System.Windows.Forms.Button btnResetConfig;
         private System.Windows.Forms.Button btnUpdate;

+ 4 - 3
Optimizer/Forms/MainForm.cs

@@ -2051,6 +2051,7 @@ namespace Optimizer
             classicRibbonSw.ToggleChecked = Options.CurrentOptions.ClassicRibbon;
             classicContextSw.ToggleChecked = Options.CurrentOptions.ClassicMenu;
             tpmSw.ToggleChecked = Options.CurrentOptions.DisableTPMCheck;
+            compactModeSw.ToggleChecked = Options.CurrentOptions.CompactMode;
         }
 
         private void Main_Load(object sender, EventArgs e)
@@ -2101,7 +2102,7 @@ namespace Optimizer
 
         private void GetStartupItems()
         {
-            _startUpItems = Utilities.GetStartupItems();
+            _startUpItems = StartupHelper.GetStartupItems();
             listStartupItems.Items.Clear();
 
             for (int i = 0; i < _startUpItems.Count; i++)
@@ -2121,7 +2122,7 @@ namespace Optimizer
             listModernApps.Enabled = false;
 
             listModernApps.Items.Clear();
-            _modernApps = Utilities.GetModernApps(showAll);
+            _modernApps = UWPHelper.GetUWPApps(showAll);
 
             foreach (string x in _modernApps)
             {
@@ -2164,7 +2165,7 @@ namespace Optimizer
 
                     foreach (string app in listModernApps.CheckedItems)
                     {
-                        await Task.Run(() => errorOccured = Utilities.UninstallModernApp(app));
+                        await Task.Run(() => errorOccured = UWPHelper.UninstallUWPApp(app));
 
                         if (errorOccured)
                         {

+ 1 - 1
Optimizer/Forms/MainForm.resx

@@ -715,7 +715,7 @@ any application only by typing your desired keyword.</value>
         AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
         LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
         ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAC0
-        GgAAAk1TRnQBSQFMAgEBCQEAATABBwEwAQcBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
+        GgAAAk1TRnQBSQFMAgEBCQEAATgBBwE4AQcBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
         AwABYAMAAQEBAAEgBgABwP8A/wD/AP8A/wD/AP8A/wAeAANHAYB0//8AiQADRwGAdP//AIkAAyoBQANH
         AYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANH
         AYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGA/wD/AP8A

+ 6 - 6
Optimizer/Forms/StartupRestoreForm.cs

@@ -124,11 +124,11 @@ namespace Optimizer
 
                         if (x.StartupType == StartupItemType.Run.ToString())
                         {
-                            keyPath = Utilities.LocalMachineRun;
+                            keyPath = StartupHelper.LocalMachineRun;
                         }
                         else if (x.StartupType == StartupItemType.RunOnce.ToString())
                         {
-                            keyPath = Utilities.LocalMachineRunOnce;
+                            keyPath = StartupHelper.LocalMachineRunOnce;
                         }
                     }
                     else if (x.RegistryLocation == StartupItemLocation.HKLMWoW.ToString())
@@ -137,11 +137,11 @@ namespace Optimizer
 
                         if (x.StartupType == StartupItemType.Run.ToString())
                         {
-                            keyPath = Utilities.LocalMachineRunWoW;
+                            keyPath = StartupHelper.LocalMachineRunWoW;
                         }
                         else if (x.StartupType == StartupItemType.RunOnce.ToString())
                         {
-                            keyPath = Utilities.LocalMachineRunOnceWow;
+                            keyPath = StartupHelper.LocalMachineRunOnceWow;
                         }
                     }
                     else if (x.RegistryLocation == StartupItemLocation.HKCU.ToString())
@@ -150,11 +150,11 @@ namespace Optimizer
 
                         if (x.StartupType == StartupItemType.Run.ToString())
                         {
-                            keyPath = Utilities.CurrentUserRun;
+                            keyPath = StartupHelper.CurrentUserRun;
                         }
                         else if (x.StartupType == StartupItemType.RunOnce.ToString())
                         {
-                            keyPath = Utilities.CurrentUserRunOnce;
+                            keyPath = StartupHelper.CurrentUserRunOnce;
                         }
                     }
 

+ 2 - 0
Optimizer/Optimizer.csproj

@@ -219,9 +219,11 @@
       <DependentUpon>StartupRestoreForm.cs</DependentUpon>
     </Compile>
     <Compile Include="StartupBackupItem.cs" />
+    <Compile Include="StartupHelper.cs" />
     <Compile Include="StartupItem.cs" />
     <Compile Include="TokenPrivilege.cs" />
     <Compile Include="Utilities.cs" />
+    <Compile Include="UWPHelper.cs" />
     <EmbeddedResource Include="Controls\ToggleCard.resx">
       <DependentUpon>ToggleCard.cs</DependentUpon>
     </EmbeddedResource>

+ 1 - 1
Optimizer/PingerHelper.cs

@@ -7,7 +7,7 @@ using System.Net.Sockets;
 
 namespace Optimizer
 {
-    internal class PingerHelper
+    internal static class PingerHelper
     {
         internal static string[] GoogleDNSv4 = { "8.8.8.8", "8.8.4.4" };
         internal static string[] GoogleDNSv6 = { "2001:4860:4860::8888", "2001:4860:4860::8844" };

+ 0 - 1
Optimizer/Resources/i18n/AR.json

@@ -73,7 +73,6 @@
 	"txtModernAppsTitle": "قم بإلغاء تثبيت تطبيقات UWP غير المرغوب فيها",
 	"chkSelectAllModernApps": "تحديد الكل",
 	"chkOnlyRemovable": "فقط إلغاء التثبيت",
-	"txtUWP": "إذا قمت بإلغاء تثبيت المتجر\nفلن تتمكن\n من تثبيت تطبيقات UWP الجديدة!\n\nأيضًا، لا يمكن إزالة بعض التطبيقات.\n\nمثل Microsoft Edge،\nالإعدادات، وما إلى ذلك.",
 	"startupTitle": "اختر عناصر بدء التشغيل الخاصة بك",
 	"removeStartupItemB": "حذف",
 	"locateFileB": "Locate file",

+ 0 - 1
Optimizer/Resources/i18n/CN.json

@@ -73,7 +73,6 @@
 	"txtModernAppsTitle": "卸载不想要的UWP应用程序",
 	"chkSelectAllModernApps": "全选",
 	"chkOnlyRemovable": "只卸载可以卸载的程序",
-	"txtUWP": "如果你卸载了应用商店App Store\n,你将无法安装新的UWP应用程序!此外,有些应用程序不能卸载。就像Microsoft Edge,设置等.",
 	"flushDNSMessage": "您确定要刷新 Windows 的 DNS 缓存吗?\n\n这将导致互联网断开一会儿,可能需要重新启动才能正常运行.",
 	"startupTitle": "选择启动项目",
 	"removeStartupItemB": "删除",

+ 0 - 1
Optimizer/Resources/i18n/CZ.json

@@ -74,7 +74,6 @@
 	"txtModernAppsTitle": "Odinstalovat nepotřebné UWP aplikace",
 	"chkSelectAllModernApps": "Vybrat vše",
 	"chkOnlyRemovable": "Pouze s možností odinstalace",
-	"txtUWP": "Pokud odinstaluje Store\nnebudete moci\ninstalovat nové UWP aplikace!\n\nNěkteré aplikace\nnemohou být odinstalovány.\n\nJako například Microsoft Edge,\nNastavení, atd.",
 	"startupTitle": "Vyberte, jaké položky se mají spustit po spuštění systému",
 	"flushDNSMessage": "Jste si jisti, že chcete propláchnout mezipaměť DNS systému Windows?\n\nTo na chvíli způsobí odpojení od internetu a pro správnou funkci může být nutný restart.",
 	"removeStartupItemB": "Odstranit",

+ 0 - 1
Optimizer/Resources/i18n/DE.json

@@ -73,7 +73,6 @@
 	"txtModernAppsTitle": "Unerwünschte UWP-Apps deinstallieren",
 	"chkSelectAllModernApps": "Alles auswählen",
 	"chkOnlyRemovable": "Nur Deinstallierbare",
-	"txtUWP": "Wenn Sie den Store deinstallieren,\nkönnen Sie keine neuen UWP-Apps installieren!\n\nAuch einige Apps können nicht deinstalliert werden.\n\nWie Microsoft Edge,\nEinstellungen, etc.",
 	"flushDNSMessage": "Sind Sie sicher, dass Sie den DNS-Cache von Windows leeren möchten?\n\nDies führt zu einer kurzzeitigen Unterbrechung der Internetverbindung, und möglicherweise ist ein Neustart erforderlich, um ordnungsgemäß zu funktionieren.",
 	"startupTitle": "Wählen Sie Ihre Startup-Elemente",
 	"removeStartupItemB": "Entfernen",

+ 0 - 1
Optimizer/Resources/i18n/EL.json

@@ -73,7 +73,6 @@
 	"txtModernAppsTitle": "Απεγκατάσταση ανεπιθύμητων εφαρμογών UWP",
 	"chkSelectAllModernApps": "Επιλογή όλων",
 	"chkOnlyRemovable": "Μόνο διαθέσιμα προς απεγκατάσταση",
-	"txtUWP": "Εαν απεγκαταστήσετε το Store\nδεν θα μπορείτε\nνα εγκαναστήσετε νέες εφαρμογές UWP!\n\nΕπίσης, κάποιες εφαρμογές\nδεν μπορούν να απεγκατασταθούν.\n\nΌπως ο Microsoft Edge,\nοι Ρυθμίσεις, κτλ.",
 	"startupTitle": "Επιλογή Στοιχείων Εκκίνησης",
 	"removeStartupItemB": "Διαγραφή",
 	"locateFileB": "Εντοπισμός αρχείου",

+ 0 - 1
Optimizer/Resources/i18n/EN.json

@@ -72,7 +72,6 @@
 	"chkSelectAllModernApps": "Select all",
 	"chkOnlyRemovable": "Only Uninstall-ables",
 	"onedriveM": "Are you sure you want to uninstall OneDrive? This will delete your Desktop and Document files! Only use this option on a local account!",
-	"txtUWP": "If you uninstall Store\nyou won't be able\nto install new UWP apps!\n\nAlso, some apps\ncan't be uninstalled.\n\nLike Microsoft Edge,\nSettings, etc.",
 	"startupTitle": "Choose your startup items",
 	"removeStartupItemB": "Delete",
 	"locateFileB": "Locate file",

+ 0 - 1
Optimizer/Resources/i18n/ES.json

@@ -74,7 +74,6 @@
 	"txtModernAppsTitle": "Desinstalar UWP apps no deseadas",
 	"chkSelectAllModernApps": "Seleccionar todo",
 	"chkOnlyRemovable": "Solo desinstalables",
-	"txtUWP": "Si desinstala Store\nno podrás\ninstalar nuevas aplicaciones para UWP!\n\nAdemás, algunas aplicaciones\nno se pueden desinstalar.\n\nEjem. Microsoft Edge,\nSettings, etc.",
 	"flushDNSMessage": "¿Está seguro de que desea vaciar la caché DNS de Windows?\n\nEsto causará la desconexión de Internet por un momento y puede ser necesario un reinicio para que funcione correctamente.",
 	"startupTitle": "Elija sus elementos de inicio",
 	"removeStartupItemB": "Borrar",

+ 0 - 1
Optimizer/Resources/i18n/FR.json

@@ -74,7 +74,6 @@
 	"txtModernAppsTitle": "Desinstaller les applications UWP indesirables",
 	"chkSelectAllModernApps": "Selectionner tout",
 	"chkOnlyRemovable": "Uniquement les desinstallables",
-	"txtUWP": "Si vous desinstallez Store\nvous ne pourrez pas\ninstaller de nouvelles applications UWP !\n\nDe plus, certaines applications\nne peuvent pas etre desinstallees.\n\nComme Microsoft Edge,\nParametres, etc.",
 	"flushDNSMessage": "Êtes-vous sûr de vouloir vider le cache DNS de Windows?\n\nCela entraînera une déconnexion d'Internet pendant un moment et un redémarrage peut être nécessaire pour que le système fonctionne correctement.",
 	"startupTitle": "Choisissez vos elements de demarrage",
 	"removeStartupItemB": "Supprimer",

+ 0 - 1
Optimizer/Resources/i18n/IT.json

@@ -65,7 +65,6 @@
 	"txtModernAppsTitle": "Disinstalla app UWP indesiderate",
 	"chkSelectAllModernApps": "Seleziona tutto",
 	"chkOnlyRemovable": "Mostra solo app removibili",
-	"txtUWP": "Se disinstalli lo Store\nnon sarai in grado\ndi installare nuove app UWP!\n\nTra l'altro, alcune app\nnon possono essere disinstallate.\n\nEs.: Microsoft Edge,\nImpostazioni, ecc.",
 	"flushDNSMessage": "Sei sicuro di voler svuotare la cache DNS di Windows?\n\nQuesto causerà la disconnessione da internet per un momento e potrebbe essere necessario un riavvio per funzionare correttamente.",
 	"startupTitle": "Scegli cosa mantenere in avvio",
 	"removeStartupItemB": "Rimuovi",

+ 0 - 1
Optimizer/Resources/i18n/KO.json

@@ -74,7 +74,6 @@
 	"txtModernAppsTitle": "불필요한 UWP 앱 제거",
 	"chkSelectAllModernApps": "모두 선택",
 	"chkOnlyRemovable": "제거 가능한 것만",
-	"txtUWP": "Store를 제거하면\n새 UWP 앱을 설치할 수 없습니다!\n\n또한 일부 앱을\n제거할 수 없습니다.\n\nMicrosoft Edge,\n설정 등입니다.",
 	"startupTitle": "시작 항목을 선택하십시오",
 	"removeStartupItemB": "삭제",
 	"locateFileB": "파일 찾기",

+ 0 - 1
Optimizer/Resources/i18n/PL.json

@@ -73,7 +73,6 @@
 	"txtModernAppsTitle": "Odinstaluj niechciane aplikacje UPW",
 	"chkSelectAllModernApps": "Zaznacz wszystko",
 	"chkOnlyRemovable": "Ukryj nie możliwe do odinstalowania",
-	"txtUWP": "Jeśli odinstalujesz Microsoft Store\nnie będziesz w stanie\nto instalować aplikacji UWP!\n\nNiektóre programy nie mogą\nbyć odinstalowane.\n\nTakie jak Microsoft Edge,\nUstawienia, itd.",
 	"startupTitle": "Wybierz elementy autostartu",
 	"removeStartupItemB": "Usuń",
 	"locateFileB": "Otwórz lokalizację",

+ 0 - 1
Optimizer/Resources/i18n/PT.json

@@ -74,7 +74,6 @@
 	"txtModernAppsTitle": "Desinstalar Aplicativos Indesejados",
 	"chkSelectAllModernApps": "Selecionar Todos",
 	"chkOnlyRemovable": "Apenas Desinstaláveis",
-	"txtUWP": "Se você desinstalar a loja de aplicativos 'Microsoft Store'\nvocê não vai poder instalar novos aplicativos da loja!\n\nAlém disso, alguns aplicativos\nnão pode ser desinstalado.\n\nComo o navegador Microsoft Edge,\nConfigurações, etc.",
 	"startupTitle": "Escolha os aplicativos que iniciarão com o sistema",
 	"flushDNSMessage": "Você tem certeza de que deseja lavar o cache DNS do Windows?\n\nIsto causará a desconexão da Internet por um momento e pode ser necessário reiniciar para funcionar corretamente.",
 	"removeStartupItemB": "Remover",

+ 0 - 1
Optimizer/Resources/i18n/RU.json

@@ -74,7 +74,6 @@
 	"txtModernAppsTitle": "Удалить ненужные UWP приложения",
 	"chkSelectAllModernApps": "Выбрать все",
 	"chkOnlyRemovable": "Только деинсталляторы",
-	"txtUWP": "Если вы удалите Магазин,\nто вы не сможете\nустановить новые UWP приложения!\n\nКроме того, некоторые приложения\nнельзя будет удалить.\n\nКак Microsoft Edge,\nНастройки и т.д.",
 	"startupTitle": "Выберите элементы автозагрузки",
 	"removeStartupItemB": "Удалить",
 	"locateFileB": "Найти файл",

+ 0 - 1
Optimizer/Resources/i18n/TR.json

@@ -74,7 +74,6 @@
 	"txtModernAppsTitle": "İstenmeyen UWP Uygulamalarını Kaldırın",
 	"chkSelectAllModernApps": "Hepsini seç",
 	"chkOnlyRemovable": "Yalnızca Kaldırılabilir Olanlar",
-	"txtUWP": "Eğer Microsoft Mağazasını kaldırırsanız\nYeni UWP Uygulamalarını yükleyemezsiniz!\n\nAyrıca bazı uygulamalar kaldırılamaz.\nMicrosoft Edge, Ayarlar gibi..",
 	"flushDNSMessage": "Windows'un DNS önbelleğini temizlemek istediğinizden emin misiniz?\n\nBu, bir an için internet bağlantısının kesilmesine neden olur ve düzgün çalışması için yeniden başlatma gerekebilir.",
 	"startupTitle": "Başlangıç öğelerinizi seçin",
 	"removeStartupItemB": "Kaldır",

+ 0 - 1
Optimizer/Resources/i18n/TW.json

@@ -74,7 +74,6 @@
 	"txtModernAppsTitle": "解除安裝不想要的UWP應用程式",
 	"chkSelectAllModernApps": "全選",
 	"chkOnlyRemovable": "只解除安裝可以解除安裝的程序",
-	"txtUWP": "如果你解除安裝了應用商店App Store\n,你將無法安裝新的UWP應用程式!此外,有些應用程式不能解除安裝。就像Microsoft Edge,設置等.",
 	"flushDNSMessage": "您確定要刷新 Windows 的 DNS 緩存嗎?\n\n這會讓網路斷開一下子,可能需要重新啟動才能正常運作.",
 	"startupTitle": "選擇啟動項目",
 	"removeStartupItemB": "刪除",

+ 177 - 0
Optimizer/StartupHelper.cs

@@ -0,0 +1,177 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+
+namespace Optimizer
+{
+    internal static class StartupHelper
+    {
+        internal static readonly string LocalMachineRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
+        internal static readonly string LocalMachineRunOnce = "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
+        internal static readonly string LocalMachineRunWoW = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run";
+        internal static readonly string LocalMachineRunOnceWow = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
+        internal static readonly string CurrentUserRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
+        internal static readonly string CurrentUserRunOnce = "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
+
+        internal static readonly string LocalMachineStartupFolder = CleanHelper.ProgramData + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
+        internal static readonly string CurrentUserStartupFolder = CleanHelper.ProfileAppDataRoaming + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
+
+        private static void GetRegistryStartupItemsHelper(ref List<StartupItem> list, StartupItemLocation location, StartupItemType type)
+        {
+            string keyPath = string.Empty;
+            RegistryKey hive = null;
+
+            if (location == StartupItemLocation.HKLM)
+            {
+                hive = Registry.LocalMachine;
+
+                if (type == StartupItemType.Run)
+                {
+                    keyPath = LocalMachineRun;
+                }
+                else if (type == StartupItemType.RunOnce)
+                {
+                    keyPath = LocalMachineRunOnce;
+                }
+            }
+            else if (location == StartupItemLocation.HKLMWoW)
+            {
+                hive = Registry.LocalMachine;
+
+                if (type == StartupItemType.Run)
+                {
+                    keyPath = LocalMachineRunWoW;
+                }
+                else if (type == StartupItemType.RunOnce)
+                {
+                    keyPath = LocalMachineRunOnceWow;
+                }
+            }
+            else if (location == StartupItemLocation.HKCU)
+            {
+                hive = Registry.CurrentUser;
+
+                if (type == StartupItemType.Run)
+                {
+                    keyPath = CurrentUserRun;
+                }
+                else if (type == StartupItemType.RunOnce)
+                {
+                    keyPath = CurrentUserRunOnce;
+                }
+            }
+
+            if (hive != null)
+            {
+                try
+                {
+                    RegistryKey key = hive.OpenSubKey(keyPath, true);
+
+                    if (key != null)
+                    {
+                        string[] valueNames = key.GetValueNames();
+
+                        foreach (string x in valueNames)
+                        {
+                            try
+                            {
+                                RegistryStartupItem item = new RegistryStartupItem();
+                                item.Name = x;
+                                item.FileLocation = key.GetValue(x).ToString();
+                                item.Key = key;
+                                item.RegistryLocation = location;
+                                item.StartupType = type;
+
+                                list.Add(item);
+                            }
+                            catch (Exception ex)
+                            {
+                                ErrorLogger.LogError("Utilities.GetRegistryStartupItemsHelper", ex.Message, ex.StackTrace);
+                            }
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    ErrorLogger.LogError("Utilities.GetRegistryStartupItemsHelper", ex.Message, ex.StackTrace);
+                }
+            }
+        }
+
+        private static void GetFolderStartupItemsHelper(ref List<StartupItem> list, string[] files, string[] shortcuts)
+        {
+            foreach (string file in files)
+            {
+                try
+                {
+                    FolderStartupItem item = new FolderStartupItem();
+                    item.Name = Path.GetFileNameWithoutExtension(file);
+                    item.FileLocation = file;
+                    item.Shortcut = file;
+                    item.RegistryLocation = StartupItemLocation.Folder;
+
+                    list.Add(item);
+                }
+                catch (Exception ex)
+                {
+                    ErrorLogger.LogError("Utilities.GetFolderStartupItemsHelper", ex.Message, ex.StackTrace);
+                }
+            }
+
+            foreach (string shortcut in shortcuts)
+            {
+                try
+                {
+                    FolderStartupItem item = new FolderStartupItem();
+                    item.Name = Path.GetFileNameWithoutExtension(shortcut);
+                    item.FileLocation = Utilities.GetShortcutTargetFile(shortcut);
+                    item.Shortcut = shortcut;
+                    item.RegistryLocation = StartupItemLocation.Folder;
+
+                    list.Add(item);
+                }
+                catch (Exception ex)
+                {
+                    ErrorLogger.LogError("Utilities.GetFolderStartupItemsHelper", ex.Message, ex.StackTrace);
+                }
+            }
+        }
+
+        internal static List<StartupItem> GetStartupItems()
+        {
+            List<StartupItem> startupItems = new List<StartupItem>();
+
+            GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLM, StartupItemType.Run);
+            GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLM, StartupItemType.RunOnce);
+
+            GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKCU, StartupItemType.Run);
+            GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKCU, StartupItemType.RunOnce);
+
+            if (Environment.Is64BitOperatingSystem)
+            {
+                GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLMWoW, StartupItemType.Run);
+                GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLMWoW, StartupItemType.RunOnce);
+            }
+
+            if (Directory.Exists(CurrentUserStartupFolder))
+            {
+                string[] currentUserFiles = Directory.EnumerateFiles(CurrentUserStartupFolder, "*.*", SearchOption.AllDirectories)
+                .Where(s => s.EndsWith(".exe") || s.EndsWith(".bat")).ToArray();
+                string[] currentUserShortcuts = Directory.GetFiles(CurrentUserStartupFolder, "*.lnk", SearchOption.AllDirectories);
+                GetFolderStartupItemsHelper(ref startupItems, currentUserFiles, currentUserShortcuts);
+            }
+
+            if (Directory.Exists(LocalMachineStartupFolder))
+            {
+                string[] localMachineFiles = Directory.EnumerateFiles(LocalMachineStartupFolder, "*.*", SearchOption.AllDirectories)
+                .Where(s => s.EndsWith(".exe") || s.EndsWith(".bat")).ToArray();
+                string[] localMachineShortcuts = Directory.GetFiles(LocalMachineStartupFolder, "*.lnk", SearchOption.AllDirectories);
+                GetFolderStartupItemsHelper(ref startupItems, localMachineFiles, localMachineShortcuts);
+            }
+
+            return startupItems;
+        }
+    }
+}

+ 54 - 0
Optimizer/UWPHelper.cs

@@ -0,0 +1,54 @@
+using System.Collections.Generic;
+using System.Management.Automation;
+
+namespace Optimizer
+{
+    internal static class UWPHelper
+    {
+        internal static List<string> GetUWPApps(bool showAll)
+        {
+            List<string> modernApps = new List<string>();
+
+            using (PowerShell script = PowerShell.Create())
+            {
+                if (showAll)
+                {
+                    script.AddScript("Get-AppxPackage | Select -Unique Name | Out-String -Stream");
+                }
+                else
+                {
+                    script.AddScript(@"Get-AppxPackage | Where {$_.NonRemovable -like ""False""} | Select -Unique Name | Out-String -Stream");
+                }
+
+                string tmp = string.Empty;
+                foreach (PSObject x in script.Invoke())
+                {
+                    tmp = x.ToString().Trim();
+                    if (!string.IsNullOrEmpty(tmp) && !tmp.Contains("---") && !tmp.Equals("Name"))
+                    {
+                        modernApps.Add(tmp);
+                    }
+                }
+            }
+
+            return modernApps;
+        }
+
+        internal static bool UninstallUWPApp(string appName)
+        {
+            using (PowerShell script = PowerShell.Create())
+            {
+                script.AddScript(string.Format("Get-AppxPackage -AllUsers '{0}' | Remove-AppxPackage", appName));
+
+                script.Invoke();
+
+                return script.Streams.Error.Count > 0;
+
+                // not working on Windows 7 anymore
+                //return script.HadErrors;
+            }
+        }
+
+        // TODO: Reinstall default pre-installed apps
+    }
+}

+ 4 - 215
Optimizer/Utilities.cs

@@ -5,7 +5,6 @@ using System.Diagnostics;
 using System.Drawing;
 using System.IO;
 using System.Linq;
-using System.Management.Automation;
 using System.Reflection;
 using System.Security.AccessControl;
 using System.Security.Principal;
@@ -18,16 +17,6 @@ namespace Optimizer
 {
     internal static class Utilities
     {
-        internal static readonly string LocalMachineRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
-        internal static readonly string LocalMachineRunOnce = "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
-        internal static readonly string LocalMachineRunWoW = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run";
-        internal static readonly string LocalMachineRunOnceWow = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
-        internal static readonly string CurrentUserRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
-        internal static readonly string CurrentUserRunOnce = "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
-
-        internal static readonly string LocalMachineStartupFolder = CleanHelper.ProgramData + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
-        internal static readonly string CurrentUserStartupFolder = CleanHelper.ProfileAppDataRoaming + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
-
         // DEPRECATED
         //internal readonly static string DefaultEdgeDownloadFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
 
@@ -286,162 +275,6 @@ namespace Optimizer
             }
         }
 
-        private static void GetRegistryStartupItemsHelper(ref List<StartupItem> list, StartupItemLocation location, StartupItemType type)
-        {
-            string keyPath = string.Empty;
-            RegistryKey hive = null;
-
-            if (location == StartupItemLocation.HKLM)
-            {
-                hive = Registry.LocalMachine;
-
-                if (type == StartupItemType.Run)
-                {
-                    keyPath = LocalMachineRun;
-                }
-                else if (type == StartupItemType.RunOnce)
-                {
-                    keyPath = LocalMachineRunOnce;
-                }
-            }
-            else if (location == StartupItemLocation.HKLMWoW)
-            {
-                hive = Registry.LocalMachine;
-
-                if (type == StartupItemType.Run)
-                {
-                    keyPath = LocalMachineRunWoW;
-                }
-                else if (type == StartupItemType.RunOnce)
-                {
-                    keyPath = LocalMachineRunOnceWow;
-                }
-            }
-            else if (location == StartupItemLocation.HKCU)
-            {
-                hive = Registry.CurrentUser;
-
-                if (type == StartupItemType.Run)
-                {
-                    keyPath = CurrentUserRun;
-                }
-                else if (type == StartupItemType.RunOnce)
-                {
-                    keyPath = CurrentUserRunOnce;
-                }
-            }
-
-            if (hive != null)
-            {
-                try
-                {
-                    RegistryKey key = hive.OpenSubKey(keyPath, true);
-
-                    if (key != null)
-                    {
-                        string[] valueNames = key.GetValueNames();
-
-                        foreach (string x in valueNames)
-                        {
-                            try
-                            {
-                                RegistryStartupItem item = new RegistryStartupItem();
-                                item.Name = x;
-                                item.FileLocation = key.GetValue(x).ToString();
-                                item.Key = key;
-                                item.RegistryLocation = location;
-                                item.StartupType = type;
-
-                                list.Add(item);
-                            }
-                            catch (Exception ex)
-                            {
-                                ErrorLogger.LogError("Utilities.GetRegistryStartupItemsHelper", ex.Message, ex.StackTrace);
-                            }
-                        }
-                    }
-                }
-                catch (Exception ex)
-                {
-                    ErrorLogger.LogError("Utilities.GetRegistryStartupItemsHelper", ex.Message, ex.StackTrace);
-                }
-            }
-        }
-
-        private static void GetFolderStartupItemsHelper(ref List<StartupItem> list, string[] files, string[] shortcuts)
-        {
-            foreach (string file in files)
-            {
-                try
-                {
-                    FolderStartupItem item = new FolderStartupItem();
-                    item.Name = Path.GetFileNameWithoutExtension(file);
-                    item.FileLocation = file;
-                    item.Shortcut = file;
-                    item.RegistryLocation = StartupItemLocation.Folder;
-
-                    list.Add(item);
-                }
-                catch (Exception ex)
-                {
-                    ErrorLogger.LogError("Utilities.GetFolderStartupItemsHelper", ex.Message, ex.StackTrace);
-                }
-            }
-
-            foreach (string shortcut in shortcuts)
-            {
-                try
-                {
-                    FolderStartupItem item = new FolderStartupItem();
-                    item.Name = Path.GetFileNameWithoutExtension(shortcut);
-                    item.FileLocation = GetShortcutTargetFile(shortcut);
-                    item.Shortcut = shortcut;
-                    item.RegistryLocation = StartupItemLocation.Folder;
-
-                    list.Add(item);
-                }
-                catch (Exception ex)
-                {
-                    ErrorLogger.LogError("Utilities.GetFolderStartupItemsHelper", ex.Message, ex.StackTrace);
-                }
-            }
-        }
-
-        internal static List<StartupItem> GetStartupItems()
-        {
-            List<StartupItem> startupItems = new List<StartupItem>();
-
-            GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLM, StartupItemType.Run);
-            GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLM, StartupItemType.RunOnce);
-
-            GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKCU, StartupItemType.Run);
-            GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKCU, StartupItemType.RunOnce);
-
-            if (Environment.Is64BitOperatingSystem)
-            {
-                GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLMWoW, StartupItemType.Run);
-                GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLMWoW, StartupItemType.RunOnce);
-            }
-
-            if (Directory.Exists(CurrentUserStartupFolder))
-            {
-                string[] currentUserFiles = Directory.EnumerateFiles(CurrentUserStartupFolder, "*.*", SearchOption.AllDirectories)
-                .Where(s => s.EndsWith(".exe") || s.EndsWith(".bat")).ToArray();
-                string[] currentUserShortcuts = Directory.GetFiles(CurrentUserStartupFolder, "*.lnk", SearchOption.AllDirectories);
-                GetFolderStartupItemsHelper(ref startupItems, currentUserFiles, currentUserShortcuts);
-            }
-
-            if (Directory.Exists(LocalMachineStartupFolder))
-            {
-                string[] localMachineFiles = Directory.EnumerateFiles(LocalMachineStartupFolder, "*.*", SearchOption.AllDirectories)
-                .Where(s => s.EndsWith(".exe") || s.EndsWith(".bat")).ToArray();
-                string[] localMachineShortcuts = Directory.GetFiles(LocalMachineStartupFolder, "*.lnk", SearchOption.AllDirectories);
-                GetFolderStartupItemsHelper(ref startupItems, localMachineFiles, localMachineShortcuts);
-            }
-
-            return startupItems;
-        }
-
         internal static void EnableFirewall()
         {
             RunCommand("netsh advfirewall set currentprofile state on");
@@ -585,50 +418,6 @@ namespace Optimizer
             }
         }
 
-        internal static List<string> GetModernApps(bool showAll)
-        {
-            List<string> modernApps = new List<string>();
-
-            using (PowerShell script = PowerShell.Create())
-            {
-                if (showAll)
-                {
-                    script.AddScript("Get-AppxPackage -AllUsers | Select -Unique Name | Out-String -Stream");
-                }
-                else
-                {
-                    script.AddScript(@"Get-AppxPackage -AllUsers | Where {$_.NonRemovable -like ""False""} | Select -Unique Name | Out-String -Stream");
-                }
-
-                string tmp = string.Empty;
-                foreach (PSObject x in script.Invoke())
-                {
-                    tmp = x.ToString().Trim();
-                    if (!string.IsNullOrEmpty(tmp) && !tmp.Contains("---") && !tmp.Equals("Name"))
-                    {
-                        modernApps.Add(tmp);
-                    }
-                }
-            }
-
-            return modernApps;
-        }
-
-        internal static bool UninstallModernApp(string appName)
-        {
-            using (PowerShell script = PowerShell.Create())
-            {
-                script.AddScript(string.Format("Get-AppxPackage -AllUsers *{0}* | Remove-AppxPackage", appName));
-
-                script.Invoke();
-
-                return script.Streams.Error.Count > 0;
-
-                // not working on Windows 7 anymore
-                //return script.HadErrors;
-            }
-        }
-
         internal static void ResetConfiguration(bool withoutRestart = false)
         {
             try
@@ -761,7 +550,7 @@ namespace Optimizer
             RegistryKey subKey = null;
 
             if (rights == null)
-                subKey = registryKey.OpenSubKey(subkeyName, RegistryKeyPermissionCheck.ReadWriteSubTree);
+                subKey = registryKey.OpenSubKey(subkeyName, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.FullControl);
             else
                 subKey = registryKey.OpenSubKey(subkeyName, RegistryKeyPermissionCheck.ReadWriteSubTree, rights.Value);
 
@@ -885,20 +674,20 @@ namespace Optimizer
         {
             try
             {
-                using (RegistryKey ifeo = Registry.LocalMachine.OpenSubKeyWritable(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"))
+                using (RegistryKey ifeo = Registry.LocalMachine.OpenSubKeyWritable(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", RegistryRights.FullControl))
                 {
                     if (ifeo == null) return;
 
                     ifeo.GrantFullControlOnSubKey("Image File Execution Options");
 
-                    using (RegistryKey k = ifeo.OpenSubKeyWritable("Image File Execution Options"))
+                    using (RegistryKey k = ifeo.OpenSubKeyWritable("Image File Execution Options", RegistryRights.FullControl))
                     {
                         if (k == null) return;
 
                         k.CreateSubKey(pName);
                         k.GrantFullControlOnSubKey(pName);
 
-                        using (RegistryKey f = k.OpenSubKeyWritable(pName))
+                        using (RegistryKey f = k.OpenSubKeyWritable(pName, RegistryRights.FullControl))
                         {
                             if (f == null) return;
 

+ 12 - 12
README.md

@@ -2,7 +2,7 @@
    <img src="https://raw.githubusercontent.com/hellzerg/optimizer/master/banner.png">
 </p> 
 
-## Summary: ##
+## ℹ️ Summary: ##
 
 Portable utility that helps you restore your privacy and increase your security.
 
@@ -39,41 +39,41 @@ Depending on your version of Windows, Optimizer will also allow you to perform s
 * Define custom commands for run dialog
 * Silent run support using a configuration file
 
-## Downloads: ##
+## ☁️ Downloads: ##
 https://github.com/hellzerg/optimizer/releases
 
-## Screenshots: ##
+## 🖼️ Screenshots: ##
 https://github.com/hellzerg/optimizer/blob/master/IMAGES.md
 
-## How to effectively disable Defender in Windows 10 1903 and later ##
+## 🆘 How to effectively disable Defender in Windows 10 1903 and later ##
 #### (https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/security-malware-windows-defender-disableantispyware) ####
 Restart in SAFE-MODE and run Optimizer with ```/disabledefender``` switch
 <br>-OR-<br>
 Execute Optimizer with ```/restart=disabledefender``` switch and let it do the rest automatically
 
-## Command-line options and silent configuration files: ##
+## 🔨 Command-line options and silent configuration files: ##
 https://github.com/hellzerg/optimizer/blob/master/CONFS.md
 
-## Frequently asked questions section: ##
+## Frequently asked questions section: ##
 https://github.com/hellzerg/optimizer/blob/master/FAQ.md
 
-## Changelog: ##
+## 📜 Changelog: ##
 https://github.com/hellzerg/optimizer/blob/master/CHANGELOG.md
 
-## Early development images: ##
+## 🖼️ Early development images: ##
 https://github.com/hellzerg/optimizer/blob/master/LEGACY.md
 
-## Compatibility: ##
+## 💻 Compatibility: ##
 
 * .NET Framework 4.5.2
 * Compatible with Windows 7, 8, 8.1, 10, 11
 * Can run under Windows Server 2008, 2012, 2016, 2019, 2022 using ```/unsafe``` switch
 
-## Tools used: ##
+## ❤️ Tools used: ##
 * ByteSize from https://github.com/omar/ByteSize
 * Thanks for this really tiny, yet extremely useful library
 
-## Credits for translating: ##
+## ❤️ Credits for translating: ##
 * https://github.com/mrkaban - mrkaban for Russian translation
 * https://github.com/theflamehd - theflamehd for German translation
 * https://github.com/Kheasyque - Kheasyque for Turkish translation
@@ -91,7 +91,7 @@ https://github.com/hellzerg/optimizer/blob/master/LEGACY.md
 ## How to include an app in Common Apps - Pull Request
 https://github.com/hellzerg/optimizer/blob/master/FEED.md
 
-## Details: ##
+## #️ Details: ##
 
 * Latest version: 13.1
 * Released: May 7, 2022