From 81d225e79802d85d3b4cddd6d8b7458717275e63 Mon Sep 17 00:00:00 2001 From: MaxXor Date: Sun, 12 Mar 2023 16:27:03 +0100 Subject: [PATCH] Add missing WOW64 subsystem autostart locations (Fixes #905) --- .../Messages/StartupManagerHandler.cs | 50 +++++++++++++++++++ Quasar.Common/Enums/StartupType.cs | 4 +- Quasar.Server/Forms/FrmStartupManager.cs | 6 +++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/Quasar.Client/Messages/StartupManagerHandler.cs b/Quasar.Client/Messages/StartupManagerHandler.cs index 2fb8d267..91b2d023 100644 --- a/Quasar.Client/Messages/StartupManagerHandler.cs +++ b/Quasar.Client/Messages/StartupManagerHandler.cs @@ -86,6 +86,28 @@ private void Execute(ISender client, GetStartupItems message) } } } + using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run")) + { + if (key != null) + { + foreach (var item in key.GetKeyValues()) + { + startupItems.Add(new Common.Models.StartupItem + { Name = item.Item1, Path = item.Item2, Type = StartupType.LocalMachineRunX86 }); + } + } + } + using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce")) + { + if (key != null) + { + foreach (var item in key.GetKeyValues()) + { + startupItems.Add(new Common.Models.StartupItem + { Name = item.Item1, Path = item.Item2, Type = StartupType.LocalMachineRunOnceX86 }); + } + } + } if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup))) { var files = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Startup)).GetFiles(); @@ -136,6 +158,20 @@ private void Execute(ISender client, DoStartupItemAdd message) throw new Exception("Could not add value"); } break; + case StartupType.LocalMachineRunX86: + if (!RegistryKeyHelper.AddRegistryKeyValue(RegistryHive.LocalMachine, + "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run", message.StartupItem.Name, message.StartupItem.Path, true)) + { + throw new Exception("Could not add value"); + } + break; + case StartupType.LocalMachineRunOnceX86: + if (!RegistryKeyHelper.AddRegistryKeyValue(RegistryHive.LocalMachine, + "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce", message.StartupItem.Name, message.StartupItem.Path, true)) + { + throw new Exception("Could not add value"); + } + break; case StartupType.StartMenu: if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup))) { @@ -196,6 +232,20 @@ private void Execute(ISender client, DoStartupItemRemove message) throw new Exception("Could not remove value"); } break; + case StartupType.LocalMachineRunX86: + if (!RegistryKeyHelper.DeleteRegistryKeyValue(RegistryHive.LocalMachine, + "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run", message.StartupItem.Name)) + { + throw new Exception("Could not remove value"); + } + break; + case StartupType.LocalMachineRunOnceX86: + if (!RegistryKeyHelper.DeleteRegistryKeyValue(RegistryHive.LocalMachine, + "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce", message.StartupItem.Name)) + { + throw new Exception("Could not remove value"); + } + break; case StartupType.StartMenu: string startupItemPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), message.StartupItem.Name); diff --git a/Quasar.Common/Enums/StartupType.cs b/Quasar.Common/Enums/StartupType.cs index 9113ed7c..983be5e6 100644 --- a/Quasar.Common/Enums/StartupType.cs +++ b/Quasar.Common/Enums/StartupType.cs @@ -6,6 +6,8 @@ public enum StartupType LocalMachineRunOnce, CurrentUserRun, CurrentUserRunOnce, - StartMenu + StartMenu, + LocalMachineRunX86, + LocalMachineRunOnceX86 } } diff --git a/Quasar.Server/Forms/FrmStartupManager.cs b/Quasar.Server/Forms/FrmStartupManager.cs index 1936de56..905daf7f 100644 --- a/Quasar.Server/Forms/FrmStartupManager.cs +++ b/Quasar.Server/Forms/FrmStartupManager.cs @@ -123,6 +123,12 @@ private void AddGroups() lstStartupItems.Groups.Add( new ListViewGroup("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce") {Tag = StartupType.CurrentUserRunOnce}); + lstStartupItems.Groups.Add( + new ListViewGroup("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run") + { Tag = StartupType.LocalMachineRunX86 }); + lstStartupItems.Groups.Add( + new ListViewGroup("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce") + { Tag = StartupType.LocalMachineRunOnceX86 }); lstStartupItems.Groups.Add(new ListViewGroup("%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup") {Tag = StartupType.StartMenu}); }