title: Running MSI uninstaller with elevated privilege
body: <p>I have created a Window Setup Project, and added a few custom installer classes to the main apps, so to include it in the Custom Action section of the Setup Project. Im not using any third party installer program just plain Visual Studio Setup project.</p>
  
  <p>I have a custom installer class for my app and in the Uninstall function I have included a function to kill the process, and remove the extra files created in the program directory.
  It work in windows XP but not in 7. So I'm assuming it has to do with UAC. How can I force run an uninstaller with admin privilege? </p>
  
  <p>here my my code for the Uninstaller override:</p>
  
  <pre><code>public override void Uninstall(IDictionary savedState)
  {
      base.Uninstall(savedState);
      try
      {
         KillProcess();
         DeleteAppPathFolder();
      }
      catch (Exception) { }
  }
  
  private void KillProcess()
  {
      for (; ; )
      {
          Process[] procMain = Process.GetProcessesByName("TaskbarNotificator");
          if (procMain.Length &gt; 0)
          {
              procMain[0].Kill();
          }
          else
              break; 
      }
  }
  
  private void DeleteAppPathFolder()
  {
      FileInfo fileInfo = new FileInfo
          (System.Reflection.Assembly.GetExecutingAssembly().Location);
  
      string sProgram = Path.Combine(fileInfo.DirectoryName, GLOBALS.APP_DIR_NAME);
  
      if (Directory.Exists(sProgram))
          Directory.Delete(sProgram, true);
  }
  </code></pre>