title: How to use setx command in a windows batch file
body: <p>I am trying to create a windows batch file to automatically set the environment variable to use python 2.4 or python 3.3.</p>
  
  <p>Both python 2.4 and 3.3 are installed on my system.  Here is my code:</p>
  
  <pre><code>::To toggle between Python24 and Python 33
  @echo on
  if (%PYTHONHOME:~-2%) == "24" (setx PYTHONHOME "C:\Python33" &amp;&amp; setx PATH %PATH:Python24=Python33% ) else (setx PYTHONHOME "C:\Python24" &amp;&amp; setx PATH %PATH:Python33=Python24% )
  pause
  </code></pre>
  
  <p>To start with I have PYTHONHOME set to <code>C:\Python24</code></p>
  
  <p><strong>But the above script gives the following error:</strong></p>
  
  <pre><code>SUCCESS: Specified value was saved.
  ERROR: Invalid syntax. Default option is not allowed more than '2' time(s).
  Type "SETX /?" for usage.
  </code></pre>
  
  <p>My PYTHONHOME still points to python 24 and nothing is changed.  The setx command does not change the environment variable.  What is causing this error?</p>