Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Microsoft.Win32;
- using System.IO;
- using System.Security.Principal;
- namespace regtest
- {
- class Program
- {
- static void Main(string[] args)
- {
- StreamWriter sw = new StreamWriter("regtest.log");
- try
- {
- RegistryKey HKLM = Registry.LocalMachine;
- try
- {
- WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
- string isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator) ? "Yes" : "No";
- sw.WriteLine("Is the user admin: " + isAdmin);
- // Apply Your path here!!
- RegistryKey General = HKLM.OpenSubKey("your\\path\\here", false);
- try
- {
- // Apply Your setting!!
- sw.WriteLine("OK: " + General.GetValue("@YOUR KEY@")");
- }
- catch (Exception c)
- {
- sw.WriteLine("Could not read key: " + c.ToString());
- }
- }
- catch (Exception b)
- {
- sw.WriteLine("Could not open path: " + b.ToString());
- }
- }
- catch (Exception a)
- {
- sw.WriteLine("Could not open HKLM: " + a.ToString());
- }
- sw.Close();
- }
- }
- }
Add Comment
Please, Sign In to add comment