I am attempting to use PowerShell to download the Python 3 installer from the Python website into a specific directory, then silently run/install the .exe file in that same directory and then add the appropriate directory to my system's PATH variable.
So far I have come up with:
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')" &&
c:\Tools\python-3.6.2.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 TargetDir=c:\Tools\Python362 &&
setx path "%PATH%;C:\Tools\Python362\" /M
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. How can I fix this?
Note:
I believe the problem stems from the use of &&, because if I use & 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 isn't any .exe file 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.
start cmd /k powershell->powershell. Make sure the destination folder already exists.