private static void RunOnStartup(MenuItem menuItem) { try { var autoStart = new AutoStart { IsEnabled = !menuItem.Checked }; menuItem.Checked = autoStart.IsEnabled; } catch (AutoStartException e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }