private void resetUserinitKey_Click(object sender, EventArgs e)
{
RegistryKey resetuserinitkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
try
{
resetuserinitkey.SetValue("Userinit", @"c:\windows\system32\userinit.exe,");
resetuserinitkey.Dispose();
ContentDialog dialog = new ContentDialog();
dialog.Title = "Information";
dialog.Content = "The Userinit key was successfully reset.";
dialog.PrimaryButtonText = "OK";
dialog.DefaultButton = ContentDialogButton.Primary;
dialog.ShowAsync();
}
catch
{
ContentDialog dialog = new ContentDialog();
dialog.Title = "Error";
dialog.Content = "There was an error resetting the Userinit key. Do I have sufficient permissions?";
dialog.PrimaryButtonText = "OK";
dialog.DefaultButton = ContentDialogButton.Primary;
dialog.ShowAsync();
}
}