@echo off rem we check de powershell version if lower that 3 exit for /f %%i in ('powershell -Command "$PSVersionTable.PSVersion.Major"') do set powershellVersion=%%i echo powershellVersion=%powershellVersion% if %powershellVersion% LSS 3 ( echo Only works with powershell greater or equal to 3 goto end ) rem we download the setup package set downloadUrl=https://cygwin.com/setup-x86_64.exe mkdir downloads 2> nul for /f %%i in ('powershell -Command "$(split-path -path "%downloadUrl%" -leaf)"') do set appFileName=%%i echo appFileName=%appFileName% rem The CMD shell does not use any great intelligence when evaluating parenthesis, and we have parenthesis in the inner command if Not exist "downloads\%appFileName%" ( rem file exists echo downloading %downloadUrl% to downloads rem we escape because we are inside if powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest %downloadUrl% -OutFile downloads\%appFileName%" ) rem we install cygwin set CYGWIN_HOME_REL_PATH=cygwin64 mkdir %CYGWIN_HOME_REL_PATH% 2> nul echo installing cygwin set packages=rsync,zip,unzip,wget,curl,openssh,openssl,xmlstarlet,jq,bind-utils,inetutils,git,mysql,python,python-pip,python3,python3-pip rem rsync,zip,unzip,wget,curl,openssh,openssl,xmlstarlet,jq,bind-utils,inetutils,git … downloads\setup-x86_64.exe --no-admin --quiet-mode --no-startmenu --no-desktop --no-shortcuts --force-current --local-package-dir "%CD%\downloads" --root "%CD%\%CYGWIN_HOME_REL_PATH%" --site "http://cygwin.mirror.constant.com/" --packages %packages% rem we fix the fstab cygwin64\bin\sed -i "s\,user \,user,noacl \g" cygwin64\etc\fstab rem we setup PATH set CYGWIN_HOME=%CD%\%CYGWIN_HOME_REL_PATH% set CYGWIN_PATH=%CYGWIN_HOME%\bin echo The Current Dir is equal to %CD% echo The CYGWIN_HOME is equal to %CYGWIN_HOME% echo The CYGWIN_HOME_REL_PATH is equal to %CYGWIN_HOME_REL_PATH% echo %PATH% | %WINDIR%\System32\find.exe "%CYGWIN_PATH%" /C >NUL IF NOT ERRORLEVEL 1 GOTO pathDuplicate SET PATH=%CYGWIN_PATH%;%PATH% echo PATH has been updated PATH = %PATH% :pathDuplicate :end