title: Elevating a ProcessBuilder process via UAC?
body: <p>I'm trying to run an external executable, but apparently it needs elevation.  The code is this, modified from an example of using ProcessBuilder (hence the array with one argument) :</p>
  
  <pre><code>    public static void main(String[] args) throws IOException {
          File demo = new File("C:\\xyzwsdemo");
          if(!demo.exists()) demo.mkdirs();
          String[] command = {"C:\\fakepath\\bsdiff4.3-win32\\bspatch.exe"};
          ProcessBuilder pb = new ProcessBuilder( command );
          Process process = pb.start();
          InputStream is = process.getInputStream();
          InputStreamReader isr = new InputStreamReader(is);
          BufferedReader br = new BufferedReader(isr);
          String line;
          System.out.printf("Output of running %s is:\n", Arrays.toString(command));
          while ((line = br.readLine()) != null) {
              System.out.println(line);
          }
          try {
              int exitValue = process.waitFor();
              System.out.println("\n\nExit Value is " + exitValue);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>It returns this when run:</p>
  
  <pre><code>Exception in thread "main" java.io.IOException: Cannot run program "C:\Users\Gilliane\Downloads\bsdiff4.3-win32\bspatch.exe": CreateProcess error=740, The requested operation requires elevation
  </code></pre>
  
  <p>I've done some browsing around, and know that in C#, you can request elevation by doing this, (as seen from <a href="https://stackoverflow.com/questions/133379/elevating-process-privilege-programatically">this thread</a>):</p>
  
  <pre><code>startInfo.Verb = "runas";
  </code></pre>
  
  <p>However, I don't see anything like that with ProcessBuilder.  Another method would be to have the <a href="http://technet.microsoft.com/en-us/magazine/2008.06.elevation.aspx" rel="noreferrer">Elevation Tools</a> installed on the target system, and to invoke the "elevate" prompt with ProcessBuilder.  However, I would rather not force the people who use my program to also install those elevation tools.</p>
  
  <p>Is there another way?</p>