private void RenameKeys() { foreach (var registryKeyEntryViewModel in Keys) { if (registryKeyEntryViewModel.WillRename && !string.IsNullOrEmpty(registryKeyEntryViewModel.Name) && !string.IsNullOrWhiteSpace(registryKeyEntryViewModel.Name) && !string.IsNullOrEmpty(registryKeyEntryViewModel.NewName) && !string.IsNullOrWhiteSpace(registryKeyEntryViewModel.NewName)) { try { bool success = RegUtils.RenameSubKey(_overlayRegistryKey, registryKeyEntryViewModel.Name, registryKeyEntryViewModel.NewName); if (!success) { MessageBox.Show(Application.Current.MainWindow, "Rename failed", App.MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); break; } } catch (Exception ex) when(ex is UnauthorizedAccessException || ex is SecurityException) { MessageBox.Show(Application.Current.MainWindow, "Unauthorised access, try running as administrator", App.MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); break; } catch (IOException ex) { MessageBox.Show(Application.Current.MainWindow, ex.Message, App.MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); } } } Init(); }