void ShowStartupAppsFromSelectedComputersExecute(object param) { var dataToShow = new List <NodeItem>(); var computers = DomainComputers?.Where(x => x.IsSelected).ToList(); foreach (var computer in computers) { // Add ping here also using (_registryEditor = new RegistryEditor(computer?.Name, LookupSource, StartRemoteRegistryServiceIfNeeded)) { Dictionary <string, string> apps = null; try { apps = _registryEditor.GetAllStartupAppsFromRegistry(SkippableSource); } catch { } var data = apps?.Select(x => new KeyValuePair <string, string>(x.Key, x.Value)).ToList(); string name = string.Empty; if (data == null) { name = $"{computer?.Name} / (Not available)"; } else if (!data.Any()) { name = $"{computer?.Name} / NO EXTRA APPS"; } else { name = $"{computer?.Name}"; } dataToShow.Add(new NodeItem { ComputerName = name, Data = new ObservableCollection <KeyValuePair <string, string> >(data ?? new List <KeyValuePair <string, string> >()) }); } } var window = new StartupAppsWindow(); var viewModel = new StartupAppsWindowViewModel(dataToShow); window.DataContext = viewModel; window.Show(); }
void ShowStartupAppsExecute(object param) { using (_registryEditor = new RegistryEditor(MachineName, LookupSource, startServiceIfNeeded: StartRemoteRegistryServiceIfNeeded)) { try { var result = _registryEditor.GetAllStartupAppsFromRegistry(SkippableSource); StartupApps = new ObservableCollection <KeyValuePair <string, string> >(result); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }