title: Windows Batch-Script - Attempting to save variable to text file then load it back into a variable upon restart
body: <p>I'm attemting to do something probably pretty easy.</p>
  
  <p>I'm trying to allow users of a windows batch script to set the background colour and store it in a txt file which is then loaded into a variable each time they run the script.</p>
  
  <p>So far I have:</p>
  
  <p>set /p ColourOpt=&lt;%LogPath%\%UserName%_Options.Colour.log</p>
  
  <p>Which loads the contents of the .log file into the ColourOpt variable (%username% and %logpath% are already defined and are working fine).</p>
  
  <p>Then I use the following code to apply the option:</p>
  
  <pre><code>If /I '%Colouropt%'=='0f' Color 0f
  If /I '%Colouropt%'=='08' Color 08
  If /I '%Colouropt%'=='0c' Color 0c
  If /I '%Colouropt%'=='0d' Color 0d
  If /I '%Colouropt%'=='0e' Color 0e
  If /I '%Colouropt%'=='0a' Color 0a
  If /I '%Colouropt%'=='1a' Color 1a
  If /I '%Colouropt%'=='1c' Color 1c
  If /I '%Colouropt%'=='1e' Color 1e
  If /I '%Colouropt%'=='1f' Color 1f
  </code></pre>
  
  <p>This also works fine and the colour is set without issue.</p>
  
  <p>Now the problem, When i use the script to output the users colour setting to the .log file it adds spaces, which now cause the script to close instead of applying the change.</p>
  
  <p>The code used to write to the .log file:</p>
  
  <pre><code>IF /I '%Options%'=='1' Echo 0f&gt;%LogPath%\%UserName%_Options.Colour.log &amp; Set ColourOpt=0f &amp; Color 0f
  </code></pre>
  
  <p>This will save the option to the .log file and set the colour straight away, aswell as setting it in the variable.</p>
  
  <p>However this outputs the text file with a space after "0f" and a blank line under it.</p>
  
  <p>Is there a way to output without the spaces, or allow the if command to ignore spaces?</p>
  
  <p>Any help would be greatly apreciated!</p>
  
  <p>Thanks!</p>