Guest User

Untitled

a guest
Jun 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Microsoft.Win32;
  5. using System.IO;
  6. using System.Security.Principal;
  7.  
  8. namespace regtest
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. StreamWriter sw = new StreamWriter("regtest.log");
  15. try
  16. {
  17. RegistryKey HKLM = Registry.LocalMachine;
  18. try
  19. {
  20. WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
  21. string isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator) ? "Yes" : "No";
  22. sw.WriteLine("Is the user admin: " + isAdmin);
  23.  
  24. // Apply Your path here!!
  25. RegistryKey General = HKLM.OpenSubKey("your\\path\\here", false);
  26. try
  27. {
  28. // Apply Your setting!!
  29. sw.WriteLine("OK: " + General.GetValue("@YOUR KEY@")");
  30. }
  31. catch (Exception c)
  32. {
  33. sw.WriteLine("Could not read key: " + c.ToString());
  34. }
  35. }
  36. catch (Exception b)
  37. {
  38. sw.WriteLine("Could not open path: " + b.ToString());
  39. }
  40. }
  41. catch (Exception a)
  42. {
  43. sw.WriteLine("Could not open HKLM: " + a.ToString());
  44. }
  45.  
  46. sw.Close();
  47. }
  48. }
  49. }
Add Comment
Please, Sign In to add comment