@echo off
:: Откуда качаем, канал Current.
set ffn=492350f6-3a01-4f97-b9c0-c7c6ddf67d60
:: Откуда качаем, канал PerpetualVL2024.
::set ffn=7983bac0-e531-40cf-be00-fd24fe66619c
:: Для какой редакции Windows. "Default" - Windows 10-11, "Win8.1" - Windows 8.1, "Win7" - Windows 7
set "winred=Default"
:: Разрядность 64 или 32
set arch=64
:: Язык
set lang=ru-ru
::------------------------------------------------------------------------------
set "aria2ver=release-1.37.0"
set "aria2folder=aria2-1.37.0-win-32bit-build1"
cd /d %~dp0
powershell -nop -command "& { (New-Object Net.WebClient).DownloadFile('https://mrodevicemgr.officeapps.live.com/mrodevicemgrsvc/api/v2/C2RReleaseData', '%tmp%\ver.txt') }" >nul 2>&1
if NOT EXIST "%tmp%\ver.txt" powershell -nop -c "$Tls12 = [Enum]::ToObject([System.Net.SecurityProtocolType], 3072); [System.Net.ServicePointManager]::SecurityProtocol = $Tls12; (New-Object Net.WebClient).DownloadFile('https://mrodevicemgr.officeapps.live.com/mrodevicemgrsvc/api/v2/C2RReleaseData','%tmp%\ver.txt')" >nul 2>&1
if EXIST "%tmp%\ver.txt" (
setlocal enabledelayedexpansion
set i=0& set j=0
for /f "tokens=1,2 delims=: " %%a in (%tmp%\ver.txt) do (
if "%%a"==""Name"" if "%%b"==""!winred!"," set i=1
if "%%a"==""Id"" set i=0& set j=0
if "!i!"=="1" if "%%a"==""FFN"" if "%%b"==""!ffn!"," set j=1
if "!j!"=="1" if "%%a"==""AvailableBuild"" set ver=%%b& goto next
)
) else goto :eof
:next
setlocal disabledelayedexpansion
if not defined ver echo AvailableBuild not found& pause& goto :eof
set ver=%ver:~1,-2%
echo Required version: %ver%
set "array=ar-sa,1025,bg-bg,1026,zh-cn,2052,zh-tw,1028,hr-hr,1050,cs-cz,1029,da-dk,1030,nl-nl,1043,en-us,1033,et-ee,1061,fi-fi,1035,fr-fr,1036,de-de,1031,el-gr,1032,he-il,1037,hi-in,1081,hu-hu,1038,id-id,1057,it-it,1040,ja-jp,1041,kk-kz,1087,ko-kr,1042,lv-lv,1062,lt-lt,1063,ms-my,1086,nb-no,1044,pl-pl,1045,pt-br,1046,pt-pt,2070,ro-ro,1048,ru-ru,1049,sk-sk,1051,sl-si,1060,es-es,3082,sv-se,1053,th-th,1054,tr-tr,1055,uk-ua,1058,vi-vn,1066,tt-ru,1092,hy-am,1067,en-gb,2057,"
setlocal enabledelayedexpansion
:lang
for /f "tokens=1,2 delims=," %%a in ("!array!") do (if %%a==%lang% set langс=%%b)
if not defined langс set array=%array:~11,510%& goto :lang
if not defined langс goto :eof
setlocal disabledelayedexpansion
del /Q /F "%tmp%\ver.txt" >nul 2>&1
rd /Q /S "%tmp%\aria2tmp" >nul 2>&1
echo Loading aria2...
2>nul (rd /q/s "%tmp%\aria2tmp"& del /f/a/q "%tmp%\aria2tmp"& md "%tmp%\aria2tmp")&& cd /D "%tmp%\aria2tmp"|| (pause& goto :eof)
curl -LO# https://github.com/aria2/aria2/releases/download/%aria2ver%/%aria2folder%.zip >nul 2>&1
if NOT EXIST "%tmp%\aria2tmp\%aria2folder%.zip" (
powershell -nop -command "& { (New-Object Net.WebClient).DownloadFile('https://github.com/aria2/aria2/releases/download/%aria2ver%/%aria2folder%.zip', '%tmp%\aria2tmp\%aria2folder%.zip') }" >nul 2>&1
if NOT EXIST "%tmp%\ver.txt" powershell -nop -c "$Tls12 = [Enum]::ToObject([System.Net.SecurityProtocolType], 3072); [System.Net.ServicePointManager]::SecurityProtocol = $Tls12; (New-Object Net.WebClient).DownloadFile('https://github.com/aria2/aria2/releases/download/%aria2ver%/%aria2folder%.zip','%tmp%\aria2tmp\%aria2folder%.zip')" >nul 2>&1
)
powershell -nop -c Expand-Archive -LiteralPath '%tmp%\aria2tmp\%aria2folder%.zip' -DestinationPath '%tmp%\aria2tmp' >nul 2>&1
if NOT EXIST "%tmp%\aria2tmp\%aria2folder%" (
call :unziparch
cscript /Nologo j_unzip.vbs "%aria2folder%.zip" >nul 2>&1
)
set url=http://officecdn.microsoft.com.edgesuite.net/DB/%ffn%/Office/Data
set "a2c=%tmp%\aria2tmp\%aria2folder%\aria2c.exe"
set "a2cp= -Z -R -s10 -x10 -c --file-allocation=trunc --summary-interval=0 --console-log-level=error "
cd /d %~dp0
set "archx=%arch%"
if %arch% == 32 set "archx=86"
%a2c%%a2cp% -dOffice\Data %url%/v%arch%.cab %url%/v%arch%_%ver%.cab
%a2c%%a2cp% -dOffice\Data\%ver% ^
%url%/%ver%/sp%arch%%langс%.cab ^
%url%/%ver%/stream.x%archx%.%lang%.proof.dat.cat ^
%url%/%ver%/stream.x%archx%.%lang%.proof.dat ^
%url%/%ver%/a%arch%0_exp.cab ^
%url%/%ver%/i%arch%%langс%.cab ^
%url%/%ver%/s%arch%%langс%.cab ^
%url%/%ver%/stream.x%archx%.%lang%.dat ^
%url%/%ver%/stream.x%archx%.%lang%.dat.cat ^
%url%/%ver%/i%arch%0.cab ^
%url%/%ver%/i%arch%0.cab.cat ^
%url%/%ver%/s%arch%0.cab ^
%url%/%ver%/stream.x%archx%.x-none.dat ^
%url%/%ver%/stream.x%archx%.x-none.dat.cat
if %arch% == 32 (
%a2c%%a2cp% -dOffice\Data\%ver% ^
%url%/%ver%/i640.cab ^
%url%/%ver%/i64%langс%.cab ^
%url%/%ver%/a640_exp.cab ^
%url%/%ver%/i640.cab.cat
)
echo %ffn%>Office\Data\branch.txt
del /Q /F "%tmp%\ver.txt" >nul 2>&1
rd /Q /S "%tmp%\aria2tmp" >nul 2>&1
timeout /t 5
goto :eof
::------------------------------- END ------------------------------
:unziparch
:: This script upzip's files...
> j_unzip.vbs ECHO '
>> j_unzip.vbs ECHO ' UnZip a file script
>> j_unzip.vbs ECHO '
>> j_unzip.vbs ECHO ' It's a mess, I know!!!
>> j_unzip.vbs ECHO '
>> j_unzip.vbs ECHO.
>> j_unzip.vbs ECHO ' Dim ArgObj, var1, var2
>> j_unzip.vbs ECHO Set ArgObj = WScript.Arguments
>> j_unzip.vbs ECHO.
>> j_unzip.vbs ECHO If (Wscript.Arguments.Count ^> 0) Then
>> j_unzip.vbs ECHO. var1 = ArgObj(0)
>> j_unzip.vbs ECHO Else
>> j_unzip.vbs ECHO. var1 = ""
>> j_unzip.vbs ECHO End if
>> j_unzip.vbs ECHO.
>> j_unzip.vbs ECHO If var1 = "" then
>> j_unzip.vbs ECHO. strFileZIP = "example.zip"
>> j_unzip.vbs ECHO Else
>> j_unzip.vbs ECHO. strFileZIP = var1
>> j_unzip.vbs ECHO End if
>> j_unzip.vbs ECHO.
>> j_unzip.vbs ECHO 'The location of the zip file.
>> j_unzip.vbs ECHO REM Set WshShell = CreateObject("Wscript.Shell")
>> j_unzip.vbs ECHO REM CurDir = WshShell.ExpandEnvironmentStrings("%%cd%%")
>> j_unzip.vbs ECHO Dim sCurPath
>> j_unzip.vbs ECHO sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
>> j_unzip.vbs ECHO strZipFile = sCurPath ^& "\" ^& strFileZIP
>> j_unzip.vbs ECHO 'The folder the contents should be extracted to.
>> j_unzip.vbs ECHO outFolder = sCurPath ^& "\"
>> j_unzip.vbs ECHO.
>> j_unzip.vbs ECHO. WScript.Echo ( "Extracting file " ^& strFileZIP)
>> j_unzip.vbs ECHO.
>> j_unzip.vbs ECHO Set objShell = CreateObject( "Shell.Application" )
>> j_unzip.vbs ECHO Set objSource = objShell.NameSpace(strZipFile).Items()
>> j_unzip.vbs ECHO Set objTarget = objShell.NameSpace(outFolder)
>> j_unzip.vbs ECHO intOptions = 256
>> j_unzip.vbs ECHO objTarget.CopyHere objSource, intOptions
>> j_unzip.vbs ECHO.
>> j_unzip.vbs ECHO. WScript.Echo ( "Extracted." )
>> j_unzip.vbs ECHO.
exit /b