title: Windows batch file - splitting a string to set variables
body: <p>I feel like I'm going around in circles with FOR loop options.</p>
  
  <p>I'm trying to take a string (output of a command) and split it on commas, then use each value to SET, e.g.</p>
  
  <p>String: <code>USER=Andy,IP=1.2.3.4,HOSTNAME=foobar,PORT=1234</code></p>
  
  <p>So I want to split on comma and then literally use that variable in SET.  I don't know ahead of time how many many variables there will be.</p>
  
  <p>I've tried things like:</p>
  
  <pre><code>FOR %%L IN (%MYSTRING%) DO ECHO %%L
  </code></pre>
  
  <p>but that splits on the equals sign too so I end up with</p>
  
  <pre><code>USER
  Andy
  IP
  1.2.3.4
  </code></pre>
  
  <p>etc</p>
  
  <p>I just want to be able to do the following so I can <code>SET USER=Andy</code> etc, something like:</p>
  
  <pre><code>FOR %%L IN (%MYSTRING%) DO SET %%L
  </code></pre>
  
  <p>What option or flags am I missing?</p>