title: Pimp my UAC and a few questions about it
body: <p>I have this application that need to do some things in protected paths (like %PROGRAMFILES%), I know that I should be using %APPDATA%, but I can't change that for now. I have isolated all the things that could require UAC to show up on another project, here's a sample code:</p>
  
  <pre><code>using System;
  using System.Diagnostics;
  using System.IO;
  using System.Windows.Forms;
  
  class Class1
  {
      static void Main(string[] args)
      {
          try
          {
              File.CreateText(Path.Combine(Application.StartupPath, "something.txt"));
          }
          catch (UnauthorizedAccessException ex)
          {
              MessageBox.Show(ex.Message, "UnauthorizedAccessException", MessageBoxButtons.OK, MessageBoxIcon.Error);
  
              if (args.Length == 0)
              {
                  Process proc = new Process();
                  proc.StartInfo.FileName = Application.ExecutablePath;
                  proc.StartInfo.Arguments = "not again";
                  proc.StartInfo.Verb = "runas";
                  proc.Start();
              }
              else
              {
                  MessageBox.Show("Exit to avoid loop.");
              }
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
          }
      }
  }
  </code></pre>
  
  <p>So, I call this executable from my main program, and if it fails because of an unauthorized access, it will launch itself showing the UAC request.</p>
  
  <p>My questions are:</p>
  
  <p>1) I had to convert the project output from a DLL to an EXE because I couldn't find any way to request UAC elevation from a DLL, is there any easy way to do that?</p>
  
  <p>2) I also noticed that some programs show a personalized UAC message, with the program logo and all those things, let me show you an example:</p>
  
  <p><img src="https://imgur.com/mJXaj.png" alt="Ugly UAC"></p>
  
  <p><img src="https://imgur.com/ujuyd.png" alt="Personalized UAC"></p>
  
  <p>How can I do that for my program?</p>
  
  <p>3) To avoid entering in a loop when is running with elevated privileges an it gets another UnauthorizedAccessException I did that thing passing any args. What would you do to achieve the same goal?</p>
  
  <p>I think that's all for now. Thanks for your time.</p>