title: How do I install Chocolatey using C#?
body: <p>I tried running the command-line instructions from the website</p>
  
  <pre><code>iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))*
  </code></pre>
  
  <p>In a pipeline</p>
  
  <pre><code>Runspace runspace = RunspaceFactory.CreateRunspace();
  runspace.Open();
  
  // create a pipeline and feed it the script text
  Pipeline pipeline = runspace.CreatePipeline();
  pipeline.Commands.AddScript(commandToRun);
  Collection&lt;PSObject&gt; results = pipeline.Invoke();
  
  // close the runspace
  runspace.Close();
  </code></pre>
  
  <p>And by invoking a process</p>
  
  <pre><code>Process.Start("@powershell -NoProfile -ExecutionPolicy unrestricted -Command \"iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))\" &amp;&amp; SET PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin")
  </code></pre>