title: How to open a document using an application launched via NSTask?
body: <p>I've grown tired of the built-in <code>open</code> Mac OS X command, mostly because it runs programs with your actual user ID instead of the effective user ID; this results in the fact <code>sudo open Foo</code> opens Foo with its associated application with your account instead of the <code>root</code> account, and it annoys me. So I decided to make some kind of replacement.</p>
  
  <p>So far I've been successful: I can open any program under the <code>open -a</code> or <code>open -b</code> fashion, and support optionally waiting. I'm using <code>NSTask</code> for that purpose.</p>
  
  <p>However, I'd like to be able to open documents too. As far as I can see, you need to use <code>NSWorkspace</code> for that, but using <code>NSWorkspace</code> to launch programs results in them being launched with your account's credentials instead of your command line program's credentials. Which is precisely what the default <code>open</code> tool does, and precisely what I don't want.</p>
  
  <p>So, how can I have a program request that another program opens a document without using <code>NSWorkspace</code>? From the <code>NSTask</code> object, I can have the process ID, but that's about it.</p>