title: Executing another program from C#, do I need to parse the "command line" from registry myself?
body: <p>From the registry, for a given file type, I get a string containing something like this:</p>
  
  <pre><code>"C:\Program Files\AppName\Executable.exe" /arg1 /arg2 /arg3
  </code></pre>
  
  <p>or sometimes:</p>
  
  <pre><code>"C:\Program Files\AppName\Executable.exe" /arg1 /arg2 /arg3 "%1"
  </code></pre>
  
  <p>In order for me to execute this program, and pass along a filename as a parameter (which I know it accepts), do I have to parse this string myself, or is there a runtime class that will do this for me? Note that I'm not asking about handling the difference between the two in regards to whether it has a "%1" or not, but rather I need to split off the name of the executable, get the command line arguments to it separately.</p>
  
  <p>I tried just appending/injecting the full path to and name of the file to pass along into the string above and pass the whole shebang to Process.Start, but of course it expects just the filename as the single argument, so that doesn't work.</p>
  
  <p>Basically, the above would have to be done like this manually:</p>
  
  <pre><code>Process proc = new Process();
  proc.StartInfo.FileName = @"C:\Program Files\AppName\Executable.exe";
  proc.StartInfo.Arguments = "/arg1 /arg2 /arg3 \"" + fileName + "\"";
  proc.Start();
  </code></pre>
  
  <p>I tried using <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.useshellexecute(VS.71).aspx" rel="noreferrer">UseShellExecute</a>, but that didn't help. Any other pointers?</p>
  
  <p>To be clear, I want this:</p>
  
  <pre><code>String commandPath = ReadFromRegistry();
  String fullCommand = commandPath + " " + fileName; // assuming not %1
  Process.Start(fullCommand); // &lt;-- magic happens here
  </code></pre>