title: Downloading and Installing Python via a Batch file
body: <p>I am attempting to use PowerShell to download the Python&nbsp;3 installer from the Python website into a specific directory, then silently run/install the .exe in that same directory and then add the appropriate directory to my system's PATH variable.</p>
  
  <p>So far I have come up with: </p>
  
  <pre><code>start cmd /k powershell -Command "(New-Object Net.WebClient).DownloadFile('https://www.python.org/ftp/python/3.6.2/python-3.6.2.exe', 'C:/Tools/python-3.6.2.exe')" &amp;&amp; 
  c:\Tools\python-3.6.2.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 TargetDir=c:\Tools\Python362 &amp;&amp;
  setx path "%PATH%;C:\Tools\Python362\" /M
  </code></pre>
  
  <p>Unfortunately this does not work. The command window will open, and then immediately quit. I have run each of these commands separately, and when I do so they work, however when I try to run them sequentially in the same file it does not work. Any assistance would be incredibly appreciated. </p>
  
  <p>Note:
  I believe the problem stems from the use of <code>&amp;&amp;</code>, because if I use <code>&amp;</code> the CMD prompt will persist, and execute. However, this does not help me since I need the second command to execute after the first one has finished or else there is no .exe for the second command to run. I am hoping this is just a syntactic error as I am very new to creating batch files and working with the windows command line.</p>