Add missing WOW64 subsystem autostart locations (Fixes #905)

This commit is contained in:
MaxXor 2023-03-12 16:27:03 +01:00
parent 374a70fc4d
commit 81d225e798
3 changed files with 59 additions and 1 deletions

View File

@ -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);

View File

@ -6,6 +6,8 @@ public enum StartupType
LocalMachineRunOnce,
CurrentUserRun,
CurrentUserRunOnce,
StartMenu
StartMenu,
LocalMachineRunX86,
LocalMachineRunOnceX86
}
}

View File

@ -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});
}