Skip to content

Instantly share code, notes, and snippets.

@jamezrin jamezrin/Installer.bat
Last active Nov 11, 2016

What would you like to do?
Little script to install maven to your system easily
@echo off
title Easy Maven Installer Script
if defined M2_HOME (
choice /m "Maven seems to be already installed, do you want to continue?" /c YN
if errorlevel 2 (
echo The installation has been cancelled
) else if errorlevel 1 (
echo Continuing with the installation...
net file 1>nul 2>nul
if '%errorlevel%' == '0' (
goto proceed
) else (
powershell "saps -filepath %0 -verb runas" >nul 2>&1
exit /b
color 02
echo Little script to install maven to your system easily
echo There are some variables inside the script that you might want to modify
timeout 3 /nobreak >nul
:: Modify this variables to your liking
set VERSION=3.3.9
:: Modify the URL variable if your mirror folder structure is different
set URL=%MIRROR%/maven/maven-3/%VERSION%/binaries/
:: Modify this variables to the place you want maven to be installed on
set PARENT=%ProgramW6432%\Apache Maven Project\
set FOLDER=%PARENT%apache-maven-%VERSION%
set ZIP=%~dp0\
if exist %ZIP% (
goto unzip
) else (
goto download
echo Downloading the binaries from %URL%...
powershell -Command "wget %URL% -UseBasicParsing -OutFile %ZIP%"
echo Unziping the binaries to %FOLDER%...
powershell -Command "Expand-Archive -Force %ZIP% ""%PARENT%"""
echo Setting the necessary variables...
setx /m M2_HOME "%FOLDER%"
setx /m M2 "%FOLDER%\bin"
setx /m PATH "%PATH%;%FOLDER%\bin"
if defined JAVA_HOME (
echo The program has now finished, you can should be able to run maven without problems
) else (
echo The program has now finished, but there are some problems that you should fix before trying to run maven
echo WARNING: JAVA_HOME is not defined in your system and maven needs it, define it with the value of your Java Development Kit installation folder (example: C:\Program Files\Java\jdk1.8.0_73)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.