title: Correct way to deal with UAC in C#
body: <p>I have an application (Windows service) that is installed into a directory in the Program Files folder. Alongside this application is another WinForms application that is used to configure the service (amongst other things). When it does configuration, it saves changes to a config file that lives alongside the service.</p>
  
  <p>When running on Vista/Win7, UAC prevents the user from saving to the config file. What I would like to do is:</p>
  
  <ul>
  <li>put the shield icon next to the menu item used to configure</li>
  <li>prompt for UAC permissions when this item is chosen</li>
  <li>only show the icon/prompt when on an OS that requires it</li>
  <li>only show the icon/prompt when permissions are required (eg. if the application is installed somewhere that does not require UAC permission)</li>
  </ul>
  
  <p>I don't really want to run the whole application as an administrator, as it is also used for other purposes that do not require UAC permissions (so setting an application manifest file is not the correct solution). I'm also assuming (correct me if I'm wrong) that once UAC permissions have been granted, my existing process cannot perform the action and that I will need to start a new process.</p>
  
  <p>How can I best achieve this?</p>