Last active
April 28, 2024 11:57
-
-
Save nimaid/a7d6d793f2eba4020135208a57f5c532 to your computer and use it in GitHub Desktop.
Batch script to install Miniconda on Windows without user input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set ORIGDIR="%CD%" | |
set MINICONDAPATH=%USERPROFILE%\Miniconda3 | |
set CONDAEXE=%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%-condainstall.exe | |
set "OS=" | |
set "MCLINK=" | |
where conda >nul 2>nul | |
if %ERRORLEVEL% EQU 0 goto CONDAFOUND | |
:INSTALLCONDA | |
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT | |
if %OS%==32BIT set MCLINK=https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86.exe | |
if %OS%==64BIT set MCLINK=https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe | |
echo Downloading Miniconda3 (This will take while, please wait)... | |
powershell -Command "(New-Object Net.WebClient).DownloadFile('%MCLINK%', '%CONDAEXE%')" >nul 2>nul | |
if errorlevel 1 goto CONDAERROR | |
echo Installing Miniconda3 (This will also take a while, please wait)... | |
start /wait /min "Installing Miniconda3..." "%CONDAEXE%" /InstallationType=JustMe /S /D="%MINICONDAPATH%" | |
del "%CONDAEXE%" | |
if not exist "%MINICONDAPATH%\" (goto CONDAERROR) | |
"%MINICONDAPATH%\Scripts\conda.exe" init | |
if errorlevel 1 goto CONDAERROR | |
echo Miniconda3 has been installed! | |
goto END | |
:CONDAERROR | |
echo Miniconda3 install failed! | |
exit /B 1 | |
:CONDAFOUND | |
echo Conda is already installed! | |
goto END | |
:END | |
exit /B 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment