Advertisement
Guest User

Untitled

a guest
Aug 13th, 2013
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 67.12 KB | None | 0 0
  1. @echo off
  2. rem *** Author: T. Wittrock, Kiel ***
  3.  
  4. verify other 2>nul
  5. setlocal enableextensions enabledelayedexpansion
  6. if errorlevel 1 goto NoExtensions
  7.  
  8. if "%DIRCMD%" NEQ "" set DIRCMD=
  9.  
  10. cd /D "%~dp0"
  11.  
  12. set WSUSOFFLINE_VERSION=8.5
  13. title %~n0 %1 %2 %3 %4 %5 %6 %7 %8 %9
  14. echo Starting WSUS Offline Update download (v. %WSUSOFFLINE_VERSION%) for %1 %2...
  15. set DOWNLOAD_LOGFILE=..\log\download.log
  16. rem *** Execute custom initialization hook ***
  17. if exist .\custom\InitializationHook.cmd (
  18.   echo Executing custom initialization hook...
  19.   pushd .\custom
  20.   call InitializationHook.cmd
  21.   popd
  22. )
  23. if exist %DOWNLOAD_LOGFILE% (
  24.   echo. >>%DOWNLOAD_LOGFILE%
  25.   echo -------------------------------------------------------------------------------- >>%DOWNLOAD_LOGFILE%
  26.   echo. >>%DOWNLOAD_LOGFILE%
  27. )
  28. echo %DATE% %TIME% - Info: Starting WSUS Offline Update download (v. %WSUSOFFLINE_VERSION%) for %1 %2 >>%DOWNLOAD_LOGFILE%
  29. if exist .\custom\InitializationHook.cmd (
  30.   echo %DATE% %TIME% - Info: Executed custom initialization hook ^(Errorlevel: %errorlevel%^) >>%DOWNLOAD_LOGFILE%
  31. )
  32.  
  33. for %%i in (wxp w2k3 w2k3-x64) do (
  34.   if /i "%1"=="%%i" (
  35.     for %%j in (enu fra esn jpn kor rus ptg ptb deu nld ita chs cht plk hun csy sve trk ell ara heb dan nor fin) do (if /i "%2"=="%%j" goto EvalParams)
  36.   )
  37. )
  38. for %%i in (w60 w60-x64 w61 w61-x64 w62 w62-x64 ofc o2k13) do (
  39.   if /i "%1"=="%%i" (
  40.     if /i "%2"=="glb" goto EvalParams
  41.   )
  42. )
  43. for %%i in (o2k3 o2k7 o2k10) do (
  44.   if /i "%1"=="%%i" (
  45.     for %%j in (enu fra esn jpn kor rus ptg ptb deu nld ita chs cht plk hun csy sve trk ell ara heb dan nor fin) do (if /i "%2"=="%%j" goto Lang_%%j)
  46.   )
  47. )
  48. goto InvalidParams
  49.  
  50. :Lang_enu
  51. set LANG_SHORT=en
  52. goto EvalParams
  53.  
  54. :Lang_fra
  55. set LANG_SHORT=fr
  56. goto EvalParams
  57.  
  58. :Lang_esn
  59. set LANG_SHORT=es
  60. goto EvalParams
  61.  
  62. :Lang_jpn
  63. set LANG_SHORT=ja
  64. goto EvalParams
  65.  
  66. :Lang_kor
  67. set LANG_SHORT=ko
  68. goto EvalParams
  69.  
  70. :Lang_rus
  71. set LANG_SHORT=ru
  72. goto EvalParams
  73.  
  74. :Lang_ptg
  75. set LANG_SHORT=pt
  76. goto EvalParams
  77.  
  78. :Lang_ptb
  79. set LANG_SHORT=pt-br
  80. goto EvalParams
  81.  
  82. :Lang_deu
  83. set LANG_SHORT=de
  84. goto EvalParams
  85.  
  86. :Lang_nld
  87. set LANG_SHORT=nl
  88. goto EvalParams
  89.  
  90. :Lang_ita
  91. set LANG_SHORT=it
  92. goto EvalParams
  93.  
  94. :Lang_chs
  95. set LANG_SHORT=zh-cn
  96. goto EvalParams
  97.  
  98. :Lang_cht
  99. set LANG_SHORT=zh-tw
  100. goto EvalParams
  101.  
  102. :Lang_plk
  103. set LANG_SHORT=pl
  104. goto EvalParams
  105.  
  106. :Lang_hun
  107. set LANG_SHORT=hu
  108. goto EvalParams
  109.  
  110. :Lang_csy
  111. set LANG_SHORT=cs
  112. goto EvalParams
  113.  
  114. :Lang_sve
  115. set LANG_SHORT=sv
  116. goto EvalParams
  117.  
  118. :Lang_trk
  119. set LANG_SHORT=tr
  120. goto EvalParams
  121.  
  122. :Lang_ell
  123. set LANG_SHORT=el
  124. goto EvalParams
  125.  
  126. :Lang_ara
  127. set LANG_SHORT=ar
  128. goto EvalParams
  129.  
  130. :Lang_heb
  131. set LANG_SHORT=he
  132. goto EvalParams
  133.  
  134. :Lang_dan
  135. set LANG_SHORT=da
  136. goto EvalParams
  137.  
  138. :Lang_nor
  139. set LANG_SHORT=no
  140. goto EvalParams
  141.  
  142. :Lang_fin
  143. set LANG_SHORT=fi
  144. goto EvalParams
  145.  
  146. :EvalParams
  147. if "%3"=="" goto NoMoreParams
  148. for %%i in (/excludesp /excludestatics /includedotnet /includemsse /includewddefs /nocleanup /verify /exitonerror /skipsdd /skiptz /skipdownload /skipdynamic /proxy /wsus /wsusonly /wsusbyproxy) do (
  149.   if /i "%3"=="%%i" echo %DATE% %TIME% - Info: Option %%i detected >>%DOWNLOAD_LOGFILE%
  150. )
  151. if /i "%3"=="/excludesp" set EXC_SP=1
  152. if /i "%3"=="/excludestatics" set EXC_STATICS=1
  153. if /i "%3"=="/includedotnet" set INC_DOTNET=1
  154. if /i "%3"=="/includemsse" set INC_MSSE=1
  155. if /i "%3"=="/includewddefs" (
  156.   echo %1 | %SystemRoot%\system32\find.exe /I "w62" >nul 2>&1
  157.   if errorlevel 1 (set INC_WDDEFS=1) else (set INC_MSSE=1)
  158. )
  159. if /i "%3"=="/nocleanup" set CLEANUP_DL=0
  160. if /i "%3"=="/verify" set VERIFY_DL=1
  161. if /i "%3"=="/exitonerror" set EXIT_ERR=1
  162. if /i "%3"=="/skipsdd" set SKIP_SDD=1
  163. if /i "%3"=="/skiptz" set SKIP_TZ=1
  164. if /i "%3"=="/skipdownload" (
  165.   set SKIP_DL=1
  166.   set SKIP_PARAM=/skipdownload
  167. )
  168. if /i "%3"=="/skipdynamic" (if "%SKIP_PARAM%"=="" set SKIP_PARAM=/skipdynamic)
  169. if /i "%3"=="/proxy" (
  170.   set http_proxy=%4
  171.   shift /3
  172. )
  173. if /i "%3"=="/wsus" (
  174.   set WSUS_URL=%4
  175.   shift /3
  176. )
  177. if /i "%3"=="/wsusonly" set WSUS_ONLY=1
  178. if /i "%3"=="/wsusbyproxy" set WSUS_BY_PROXY=1
  179. shift /3
  180. goto EvalParams
  181.  
  182. :NoMoreParams
  183. echo %1 | %SystemRoot%\system32\find.exe /I "x64" >nul 2>&1
  184. if errorlevel 1 (set TARGET_ARCH=x86) else (set TARGET_ARCH=x64)
  185. if "%SKIP_TZ%"=="1" goto SkipTZ
  186. for /F "tokens=3" %%i in ('%SystemRoot%\system32\reg.exe QUERY HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v ActiveTimeBias ^| %SystemRoot%\system32\find.exe /I "ActiveTimeBias"') do set TZAB=%%i
  187. set TZAB=0000000!TZAB:~2!
  188. set TZAB=!TZAB:~-8!
  189. set /A TZ=(0x!TZAB:~0,4!^<^<16^|0x!TZAB:~-4!)/60, TZ_MIN=(0x!TZAB:~0,4!^<^<16^|0x!TZAB:~-4!)-(TZ*60)
  190. set TZ_MIN=0!TZ_MIN!
  191. set TZ=LOC!TZ!:!TZ_MIN:~-2!
  192. set TZ_MIN=
  193. set TZAB=
  194. echo %DATE% %TIME% - Info: Set time zone to !TZ! >>%DOWNLOAD_LOGFILE%
  195. :SkipTZ
  196. if "%TEMP%"=="" goto NoTemp
  197. pushd "%TEMP%"
  198. if errorlevel 1 goto NoTempDir
  199. popd
  200. set CSCRIPT_PATH=%SystemRoot%\system32\cscript.exe
  201. if not exist %CSCRIPT_PATH% goto NoCScript
  202. set ARIA_PATH=..\bin\aria2c.exe
  203. if not exist %ARIA_PATH% goto NoAria
  204. set ARIA_LOGGING=--console-log-level=error --log-level=warn -l %DOWNLOAD_LOGFILE%
  205. set ARIA_CONCURRENCY=--max-connection-per-server=10 --max-concurrent-downloads=10 --split=10 --min-split-size=1M
  206. set ARIA_CMDLINE=%ARIA_LOGGING%  %ARIA_CONCURRENCY% --conditional-get=true --allow-overwrite=true
  207.  
  208. if not exist ..\bin\unzip.exe goto NoUnZip
  209. if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" (set HASHDEEP_EXE=hashdeep64.exe) else (
  210.   if /i "%PROCESSOR_ARCHITEW6432%"=="AMD64" (set HASHDEEP_EXE=hashdeep64.exe) else (set HASHDEEP_EXE=hashdeep.exe)
  211. )
  212.  
  213. rem *** Clean up existing directories ***
  214. echo Cleaning up existing directories...
  215. if exist ..\iso\dummy.txt del ..\iso\dummy.txt
  216. if exist ..\log\dummy.txt del ..\log\dummy.txt
  217. if exist ..\exclude\custom\dummy.txt del ..\exclude\custom\dummy.txt
  218. if exist ..\static\custom\dummy.txt del ..\static\custom\dummy.txt
  219. if exist ..\client\exclude\custom\dummy.txt del ..\client\exclude\custom\dummy.txt
  220. if exist ..\client\static\custom\dummy.txt del ..\client\static\custom\dummy.txt
  221. if exist ..\client\software\msi\dummy.txt del ..\client\software\msi\dummy.txt
  222. if exist UpdateOU.new (
  223.   if exist UpdateOU.cmd del UpdateOU.cmd
  224.   ren UpdateOU.new UpdateOU.cmd
  225. )
  226.  
  227. rem *** Obsolete internal stuff ***
  228. if exist ActivateVistaAllLanguageServicePacks.cmd del ActivateVistaAllLanguageServicePacks.cmd
  229. if exist ActivateVistaFiveLanguageServicePacks.cmd del ActivateVistaFiveLanguageServicePacks.cmd
  230. if exist DetermineAutoDaylightTimeSet.vbs del DetermineAutoDaylightTimeSet.vbs
  231. if exist ..\doc\faq.txt del ..\doc\faq.txt
  232. if exist ..\static\StaticDownloadLinks-mkisofs.txt del ..\static\StaticDownloadLinks-mkisofs.txt
  233. if exist ..\static\StaticDownloadLink-unzip.txt del ..\static\StaticDownloadLink-unzip.txt
  234. if exist ..\static\StaticDownloadLink-msxsl.txt del ..\static\StaticDownloadLink-msxsl.txt
  235. if exist ..\client\cmd\Reboot.vbs del ..\client\cmd\Reboot.vbs
  236. if exist ..\client\cmd\Shutdown.vbs del ..\client\cmd\Shutdown.vbs
  237. if exist ..\client\msi\nul rd /S /Q ..\client\msi
  238. if exist ..\client\static\StaticUpdateIds-ie9-w61.txt del ..\client\static\StaticUpdateIds-ie9-w61.txt
  239.  
  240. rem *** Office 2000 stuff ***
  241. if exist ..\client\bin\msxsl.exe del ..\client\bin\msxsl.exe
  242. if exist ..\client\xslt\nul rd /S /Q ..\client\xslt
  243. if exist ..\client\static\StaticUpdateIds-o2k.txt del ..\client\static\StaticUpdateIds-o2k.txt
  244. del /Q ..\exclude\ExcludeList*-o2k.txt >nul 2>&1
  245. del /Q ..\static\*o2k-*.* >nul 2>&1
  246. del /Q ..\xslt\*o2k-*.* >nul 2>&1
  247. if exist ..\xslt\ExtractExpiredIds-o2k.xsl del ..\xslt\ExtractExpiredIds-o2k.xsl
  248. if exist ..\xslt\ExtractValidIds-o2k.xsl del ..\xslt\ExtractValidIds-o2k.xsl
  249.  
  250. rem *** Office XP stuff ***
  251. if exist ..\client\static\StaticUpdateIds-oxp.txt del ..\client\static\StaticUpdateIds-oxp.txt
  252. del /Q ..\exclude\ExcludeList*-oxp.txt >nul 2>&1
  253. del /Q ..\static\*oxp-*.* >nul 2>&1
  254.  
  255. rem *** .NET restructuring stuff ***
  256. if exist ..\exclude\ExcludeList-dotnet.txt del ..\exclude\ExcludeList-dotnet.txt
  257. if exist ..\client\win\glb\ndp*.* (
  258.   if not exist ..\client\dotnet\x86-glb\nul md ..\client\dotnet\x86-glb
  259.   move /Y ..\client\win\glb\ndp*.* ..\client\dotnet\x86-glb >nul
  260. )
  261. if exist ..\client\w2k3-x64\glb\ndp*.* (
  262.   if not exist ..\client\dotnet\x64-glb\nul md ..\client\dotnet\x64-glb
  263.   move /Y ..\client\w2k3-x64\glb\ndp*.* ..\client\dotnet\x64-glb >nul
  264. )
  265. if exist ..\static\StaticDownloadLink-dotnet.txt del ..\static\StaticDownloadLink-dotnet.txt
  266. if exist ..\xslt\ExtractDownloadLinks-dotnet-glb.xsl del ..\xslt\ExtractDownloadLinks-dotnet-glb.xsl
  267. if exist ..\client\static\StaticUpdateIds-dotnet.txt del ..\client\static\StaticUpdateIds-dotnet.txt
  268. if exist ..\client\dotnet\glb\nul (
  269.   if not exist ..\client\dotnet\x64-glb\nul md ..\client\dotnet\x64-glb
  270.   move /Y ..\client\dotnet\glb\*-x64_*.* ..\client\dotnet\x64-glb >nul
  271.   if not exist ..\client\dotnet\x86-glb\nul md ..\client\dotnet\x86-glb
  272.   move /Y ..\client\dotnet\glb\*-x86_*.* ..\client\dotnet\x86-glb >nul
  273.   rd /S /Q ..\client\dotnet\glb
  274. )
  275.  
  276. rem *** FCIV stuff ***
  277. if exist ..\bin\fciv.exe del ..\bin\fciv.exe
  278. if exist ..\fciv\nul rd /S /Q ..\fciv
  279. if exist ..\static\StaticDownloadLink-fciv.txt del ..\static\StaticDownloadLink-fciv.txt
  280.  
  281. rem *** WUA stuff - now statically defined ***
  282. if exist ..\xslt\ExtractDownloadLinks-wua-x86.xsl del ..\xslt\ExtractDownloadLinks-wua-x86.xsl
  283. if exist ..\xslt\ExtractDownloadLinks-wua-x64.xsl del ..\xslt\ExtractDownloadLinks-wua-x64.xsl
  284.  
  285. rem *** Microsoft Security Essentials stuff ***
  286. if exist ..\static\StaticDownloadLink-mssedefs-x64.txt del ..\static\StaticDownloadLink-mssedefs-x64.txt
  287. if exist ..\static\StaticDownloadLink-mssedefs-x86.txt del ..\static\StaticDownloadLink-mssedefs-x86.txt
  288. if exist ..\static\StaticDownloadLink-mssedefs-x64-glb.txt del ..\static\StaticDownloadLink-mssedefs-x64-glb.txt
  289. if exist ..\static\StaticDownloadLink-mssedefs-x86-glb.txt del ..\static\StaticDownloadLink-mssedefs-x86-glb.txt
  290. if exist ..\client\mssedefs\x64\nul (
  291.   if not exist ..\client\mssedefs\x64-glb\nul md ..\client\mssedefs\x64-glb
  292.   move /Y ..\client\mssedefs\x64\*.* ..\client\mssedefs\x64-glb >nul
  293.   rd /S /Q ..\client\mssedefs\x64
  294. )
  295. if exist ..\client\mssedefs\x86\nul (
  296.   if not exist ..\client\mssedefs\x86-glb\nul md ..\client\mssedefs\x86-glb
  297.   move /Y ..\client\mssedefs\x86\*.* ..\client\mssedefs\x86-glb >nul
  298.   rd /S /Q ..\client\mssedefs\x86
  299. )
  300. if exist ..\client\mssedefs\nul move /Y ..\client\mssedefs msse >nul
  301. if exist ..\client\md\hashes-mssedefs.txt del ..\client\md\hashes-mssedefs.txt
  302.  
  303. rem *** Obsolete external stuff ***
  304. if exist ..\bin\extract.exe del ..\bin\extract.exe
  305. if exist ..\bin\msxsl.exe del ..\bin\msxsl.exe
  306. if exist ..\sh\hashdeep del ..\sh\hashdeep
  307. if exist ..\static\StaticDownloadLink-extract.txt del ..\static\StaticDownloadLink-extract.txt
  308. if exist ..\static\StaticDownloadLink-sigcheck.txt del ..\static\StaticDownloadLink-sigcheck.txt
  309. if exist ..\static\StaticDownloadLink-streams.txt del ..\static\StaticDownloadLink-streams.txt
  310.  
  311. rem *** Windows 2000 stuff ***
  312. if exist ..\client\bin\reg.exe del ..\client\bin\reg.exe
  313. if exist ..\client\static\StaticUpdateIds-w2k-x86.txt del ..\client\static\StaticUpdateIds-w2k-x86.txt
  314. if exist FixIE6SetupDir.cmd del FixIE6SetupDir.cmd
  315. for %%i in (enu fra esn jpn kor rus ptg ptb deu nld ita chs cht plk hun csy sve trk ell ara heb dan nor fin) do (
  316.   if exist ..\client\win\%%i\ie6setup\nul rd /S /Q ..\client\win\%%i\ie6setup
  317. )
  318. if exist ..\exclude\ExcludeList-w2k-x86.txt del ..\exclude\ExcludeList-w2k-x86.txt
  319. if exist ..\exclude\ExcludeListISO-w2k-x86.txt del ..\exclude\ExcludeListISO-w2k-x86.txt
  320. if exist ..\exclude\ExcludeListUSB-w2k-x86.txt del ..\exclude\ExcludeListUSB-w2k-x86.txt
  321. if exist ..\sh\FIXIE6SetupDir.sh del ..\sh\FIXIE6SetupDir.sh
  322. del /Q ..\static\*ie6-*.* >nul 2>&1
  323. del /Q ..\static\*w2k-*.* >nul 2>&1
  324. del /Q ..\xslt\*w2k-*.* >nul 2>&1
  325.  
  326. rem *** Office and invcif.exe stuff ***
  327. if exist ..\static\StaticDownloadLinks-inventory.txt del ..\static\StaticDownloadLinks-inventory.txt
  328. if exist ..\client\wsus\invcif.exe (
  329.   if exist ..\client\md\hashes-wsus.txt del ..\client\md\hashes-wsus.txt
  330.   del ..\client\wsus\invcif.exe
  331. )
  332. if exist ..\client\wsus\invcm.exe (
  333.   if exist ..\client\md\hashes-wsus.txt del ..\client\md\hashes-wsus.txt
  334.   del ..\client\wsus\invcm.exe
  335. )
  336. if exist ..\client\static\StaticUpdateIds-o2k7-x*.txt del ..\client\static\StaticUpdateIds-o2k7-x*.txt
  337. if exist ..\ExtractDownloadLinks-oall.cmd del ..\ExtractDownloadLinks-oall.cmd
  338. if exist ..\ExtractDownloadLinks-wall.cmd del ..\ExtractDownloadLinks-wall.cmd
  339. if exist ..\static\StaticDownloadLinks-o2k7-x*.txt del ..\static\StaticDownloadLinks-o2k7-x*.txt
  340. if exist ..\static\StaticDownloadLinks-o2k13-x64-glb.txt del ..\static\StaticDownloadLinks-o2k13-x64-glb.txt
  341. if exist ..\xslt\ExtractDownloadLinks-oall-deu.xsl del ..\xslt\ExtractDownloadLinks-oall-deu.xsl
  342. if exist ..\xslt\ExtractDownloadLinks-oall-enu.xsl del ..\xslt\ExtractDownloadLinks-oall-enu.xsl
  343. if exist ..\xslt\ExtractDownloadLinks-oall-fra.xsl del ..\xslt\ExtractDownloadLinks-oall-fra.xsl
  344. if exist ..\xslt\ExtractDownloadLinks-wall.xsl del ..\xslt\ExtractDownloadLinks-wall.xsl
  345. del /Q ..\exclude\ExcludeList*-o2k3.txt >nul 2>&1
  346. del /Q ..\exclude\ExcludeList*-o2k7*.txt >nul 2>&1
  347. del /Q ..\exclude\ExcludeList*-o2k10.txt >nul 2>&1
  348. del /Q ..\xslt\ExtractDownloadLinks-o*.* >nul 2>&1
  349. del /Q ..\xslt\ExtractExpiredIds-o*.* >nul 2>&1
  350. del /Q ..\xslt\ExtractValidIds-o*.* >nul 2>&1
  351.  
  352. rem *** CPP restructuring stuff ***
  353. if exist ..\client\md\hashes-cpp-x64-glb.txt del ..\client\md\hashes-cpp-x64-glb.txt
  354. if exist ..\client\cpp\x64-glb\nul (
  355.   move /Y ..\client\cpp\x64-glb\*.* ..\client\cpp >nul
  356.   rd /S /Q ..\client\cpp\x64-glb
  357. )
  358. if exist ..\client\md\hashes-cpp-x86-glb.txt del ..\client\md\hashes-cpp-x86-glb.txt
  359. if exist ..\client\cpp\x86-glb\nul (
  360.   move /Y ..\client\cpp\x86-glb\*.* ..\client\cpp >nul
  361.   rd /S /Q ..\client\cpp\x86-glb
  362. )
  363.  
  364. rem *** rootsupd restructuring stuff ***
  365. if exist ..\client\wxp\glb\rootsupd.exe (
  366.   if not exist ..\client\win\glb\nul md ..\client\win\glb
  367.   move /Y ..\client\wxp\glb\rootsupd.exe ..\client\win\glb >nul
  368.   if exist ..\client\md\hashes-win-glb.txt del ..\client\md\hashes-win-glb.txt
  369.   if exist ..\client\md\hashes-wxp-glb.txt del ..\client\md\hashes-wxp-glb.txt
  370. )
  371.  
  372. rem *** Update static download definitions ***
  373. if "%SKIP_SDD%"=="1" goto SkipSDD
  374. echo Updating static download definitions...
  375. %ARIA_PATH% %ARIA_CMDLINE% -d ..\static http://download.wsusoffline.net/StaticDownloadFiles-modified.txt
  376. %ARIA_PATH% %ARIA_CMDLINE% -d ..\static -i ..\static\StaticDownloadFiles-modified.txt
  377.  
  378. echo %DATE% %TIME% - Info: Updated static download definitions >>%DOWNLOAD_LOGFILE%
  379. :SkipSDD
  380.  
  381. rem *** Download mkisofs tool ***
  382. if "%SKIP_DL%"=="1" goto SkipMkIsoFs
  383. if exist ..\bin\mkisofs.exe goto SkipMkIsoFs
  384. echo Downloading mkisofs tool...
  385. %ARIA_PATH% %ARIA_CMDLINE% -d ..\bin -i ..\static\StaticDownloadLink-mkisofs.txt
  386. if errorlevel 1 goto DownloadError
  387. echo %DATE% %TIME% - Info: Downloaded mkisofs tool >>%DOWNLOAD_LOGFILE%
  388. :SkipMkIsoFs
  389.  
  390. rem *** Download Sysinternals' tools Autologon, Sigcheck and Streams ***
  391. if not exist ..\client\bin\Autologon.exe goto DownloadSysinternals
  392. if not exist ..\bin\sigcheck.exe goto DownloadSysinternals
  393. if not exist ..\bin\streams.exe goto DownloadSysinternals
  394. goto SkipSysinternals
  395. :DownloadSysinternals
  396. echo Downloading Sysinternals' tools Autologon, Sigcheck and Streams...
  397. %ARIA_PATH% %ARIA_CMDLINE% -d ..\bin -i ..\static\StaticDownloadLinks-sysinternals.txt
  398. if errorlevel 1 goto DownloadError
  399. echo %DATE% %TIME% - Info: Downloaded Sysinternals' tools Autologon, Sigcheck and Streams >>%DOWNLOAD_LOGFILE%
  400. pushd ..\bin
  401. unzip.exe -o Autologon.zip Autologon.exe
  402. del Autologon.zip
  403. move /Y Autologon.exe ..\client\bin
  404. unzip.exe -o Sigcheck.zip sigcheck.exe
  405. del Sigcheck.zip
  406. unzip.exe -o Streams.zip streams.exe
  407. del Streams.zip
  408. popd
  409. :SkipSysinternals
  410.  
  411. rem *** Download most recent Windows Update Agent installation and catalog files ***
  412. if "%VERIFY_DL%" NEQ "1" goto DownloadWSUS
  413. if not exist ..\client\wsus\nul goto DownloadWSUS
  414. if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  415. if exist ..\client\md\hashes-wsus.txt (
  416.   echo Verifying integrity of Windows Update Agent installation and catalog files...
  417.   pushd ..\client\md
  418.   ..\bin\%HASHDEEP_EXE% -a -l -vv -k hashes-wsus.txt -r ..\wsus
  419.   if errorlevel 1 (
  420.     popd
  421.     goto IntegrityError
  422.   )
  423.   popd
  424.   echo %DATE% %TIME% - Info: Verified integrity of Windows Update Agent installation and catalog files >>%DOWNLOAD_LOGFILE%
  425. ) else (
  426.   echo Warning: Integrity database ..\client\md\hashes-wsus.txt not found.
  427.   echo %DATE% %TIME% - Warning: Integrity database ..\client\md\hashes-wsus.txt not found >>%DOWNLOAD_LOGFILE%
  428. )
  429. :DownloadWSUS
  430. echo Downloading/validating most recent Windows Update Agent installation and catalog files...
  431. %ARIA_PATH% %ARIA_CMDLINE% -d ..\client\wsus -i ..\static\StaticDownloadLinks-wsus.txt
  432. if errorlevel 1 goto DownloadError
  433. echo %DATE% %TIME% - Info: Downloaded/validated most recent Windows Update Agent installation and catalog files >>%DOWNLOAD_LOGFILE%
  434. if "%VERIFY_DL%"=="1" (
  435.   if not exist ..\bin\sigcheck.exe goto NoSigCheck
  436.   echo Verifying digital file signatures of Windows Update Agent installation and catalog files...
  437.   ..\bin\sigcheck.exe /accepteula -q -s -u -v ..\client\wsus >"%TEMP%\sigcheck-wsus.txt"
  438.   for /F "usebackq skip=1 eol=N tokens=1 delims=," %%i in ("%TEMP%\sigcheck-wsus.txt") do (
  439.     del %%i
  440.     echo Warning: Deleted unsigned file %%i.
  441.     echo %DATE% %TIME% - Warning: Deleted unsigned file %%i >>%DOWNLOAD_LOGFILE%
  442.     echo File signature verification failure >"%TEMP%\sigerror-wsus.txt"
  443.   )
  444.   if exist "%TEMP%\sigcheck-wsus.txt" del "%TEMP%\sigcheck-wsus.txt"
  445.   if exist "%TEMP%\sigerror-wsus.txt" (
  446.     if exist ..\client\md\hashes-wsus.txt del ..\client\md\hashes-wsus.txt
  447.     del "%TEMP%\sigerror-wsus.txt"
  448.     goto SignatureError
  449.   )
  450.   echo %DATE% %TIME% - Info: Verified digital file signatures of Windows Update Agent installation and catalog files >>%DOWNLOAD_LOGFILE%
  451.   if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  452.   echo Creating integrity database for Windows Update Agent installation and catalog files...
  453.   if not exist ..\client\md\nul md ..\client\md
  454.   pushd ..\client\md
  455.   ..\bin\%HASHDEEP_EXE% -c md5,sha1,sha256 -l -r ..\wsus >hashes-wsus.txt
  456.   if errorlevel 1 (
  457.     popd
  458.     echo Warning: Error creating integrity database ..\client\md\hashes-wsus.txt.
  459.     echo %DATE% %TIME% - Warning: Error creating integrity database ..\client\md\hashes-wsus.txt >>%DOWNLOAD_LOGFILE%
  460.   ) else (
  461.     popd
  462.     echo %DATE% %TIME% - Info: Created integrity database for Windows Update Agent installation and catalog files >>%DOWNLOAD_LOGFILE%
  463.   )
  464. ) else (
  465.   if exist ..\client\md\hashes-wsus.txt (
  466.     del ..\client\md\hashes-wsus.txt
  467.     echo %DATE% %TIME% - Info: Deleted integrity database for Windows Update Agent installation and catalog files >>%DOWNLOAD_LOGFILE%
  468.   )
  469. )
  470.  
  471. rem *** Download installation files for .NET Frameworks 3.5 SP1 and 4.x ***
  472. if "%INC_DOTNET%" NEQ "1" goto SkipDotNet
  473. if "%SKIP_DL%"=="1" (
  474.   call :DownloadCore dotnet %TARGET_ARCH%-glb %TARGET_ARCH% %SKIP_PARAM%
  475.   goto SkipDotNet
  476. )
  477. if "%VERIFY_DL%" NEQ "1" goto DownloadDotNet
  478. if not exist ..\client\dotnet\nul goto DownloadDotNet
  479. if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  480. if exist ..\client\md\hashes-dotnet.txt (
  481.   echo Verifying integrity of .NET Frameworks' installation files...
  482.   pushd ..\client\md
  483.   ..\bin\%HASHDEEP_EXE% -a -l -vv -k hashes-dotnet.txt ..\dotnet\dotnetfx*.exe
  484.   if errorlevel 1 (
  485.     popd
  486.     goto IntegrityError
  487.   )
  488.   popd
  489.   echo %DATE% %TIME% - Info: Verified integrity of .NET Frameworks' installation files >>%DOWNLOAD_LOGFILE%
  490. ) else (
  491.   echo Warning: Integrity database ..\client\md\hashes-dotnet.txt not found.
  492.   echo %DATE% %TIME% - Warning: Integrity database ..\client\md\hashes-dotnet.txt not found >>%DOWNLOAD_LOGFILE%
  493. )
  494. :DownloadDotNet
  495. for %%i in (..\client\md\hashes-dotnet-%TARGET_ARCH%-glb.txt) do echo _%%~ti | %SystemRoot%\system32\find.exe "_%DATE:~-10%" >nul 2>&1
  496. if not errorlevel 1 (
  497.   echo Skipping download/validation of .NET Frameworks' installation files due to 'same day' rule.
  498.   echo %DATE% %TIME% - Info: Skipped download/validation of .NET Frameworks' installation files due to 'same day' rule >>%DOWNLOAD_LOGFILE%
  499.   goto VerifyDotNet
  500. )
  501. echo Downloading/validating installation files for .NET Frameworks 3.5 SP1 and 4.x...
  502. copy /Y ..\static\StaticDownloadLinks-dotnet.txt "%TEMP%\StaticDownloadLinks-dotnet.txt" >nul
  503. if exist ..\static\custom\StaticDownloadLinks-dotnet.txt (
  504.   type ..\static\custom\StaticDownloadLinks-dotnet.txt >>"%TEMP%\StaticDownloadLinks-dotnet.txt"
  505. )
  506. %ARIA_PATH% %ARIA_CMDLINE% -d ..\client\dotnet -i ..\static\StaticDownloadLinks-dotnet.txt
  507.  
  508. if errorlevel 1 (
  509.   del "%TEMP%\StaticDownloadLinks-dotnet.txt"
  510.   goto DownloadError
  511. )
  512. echo %DATE% %TIME% - Info: Downloaded/validated installation files for .NET Frameworks 3.5 SP1 and 4.x >>%DOWNLOAD_LOGFILE%
  513. call :DownloadCore dotnet %TARGET_ARCH%-glb %TARGET_ARCH% %SKIP_PARAM%
  514. if errorlevel 1 goto Error
  515. if "%CLEANUP_DL%"=="0" (
  516.   del "%TEMP%\StaticDownloadLinks-dotnet.txt"
  517.   goto VerifyDotNet
  518. )
  519. echo Cleaning up client directory for .NET Frameworks 3.5 SP1 and 4.x...
  520. for /F %%i in ('dir ..\client\dotnet /A:-D /B') do (
  521.   %SystemRoot%\system32\find.exe /I "%%i" "%TEMP%\StaticDownloadLinks-dotnet.txt" >nul 2>&1
  522.   if errorlevel 1 (
  523.     del ..\client\dotnet\%%i
  524.     echo %DATE% %TIME% - Info: Deleted ..\client\dotnet\%%i >>%DOWNLOAD_LOGFILE%
  525.   )
  526. )
  527. del "%TEMP%\StaticDownloadLinks-dotnet.txt"
  528. echo %DATE% %TIME% - Info: Cleaned up client directory for .NET Frameworks 3.5 SP1 and 4.x >>%DOWNLOAD_LOGFILE%
  529. :VerifyDotNet
  530. if "%VERIFY_DL%"=="1" (
  531.  rem *** Verifying digital file signatures for .NET Frameworks' installation files ***
  532.   if not exist ..\bin\sigcheck.exe goto NoSigCheck
  533.   echo Verifying digital file signatures for .NET Frameworks' installation files...
  534.   ..\bin\sigcheck.exe /accepteula -q -u -v ..\client\dotnet >"%TEMP%\sigcheck-dotnet.txt"
  535.   for /F "usebackq skip=1 eol=N tokens=1 delims=," %%i in ("%TEMP%\sigcheck-dotnet.txt") do (
  536.     del %%i
  537.     echo Warning: Deleted unsigned file %%i.
  538.     echo %DATE% %TIME% - Warning: Deleted unsigned file %%i >>%DOWNLOAD_LOGFILE%
  539.   )
  540.   if exist "%TEMP%\sigcheck-dotnet.txt" del "%TEMP%\sigcheck-dotnet.txt"
  541.   echo %DATE% %TIME% - Info: Verified digital file signatures for .NET Frameworks' installation files >>%DOWNLOAD_LOGFILE%
  542.   if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  543.   echo Creating integrity database for .NET Frameworks' installation files...
  544.   if not exist ..\client\md\nul md ..\client\md
  545.   pushd ..\client\md
  546.   ..\bin\%HASHDEEP_EXE% -c md5,sha1,sha256 -l ..\dotnet\dotnetfx*.exe >hashes-dotnet.txt
  547.   if errorlevel 1 (
  548.     popd
  549.     echo Warning: Error creating integrity database ..\client\md\hashes-dotnet.txt.
  550.     echo %DATE% %TIME% - Warning: Error creating integrity database ..\client\md\hashes-dotnet.txt >>%DOWNLOAD_LOGFILE%
  551.   ) else (
  552.     popd
  553.     echo %DATE% %TIME% - Info: Created integrity database for .NET Frameworks' installation files >>%DOWNLOAD_LOGFILE%
  554.   )
  555. ) else (
  556.   if exist ..\client\md\hashes-dotnet.txt (
  557.     del ..\client\md\hashes-dotnet.txt
  558.     echo %DATE% %TIME% - Info: Deleted integrity database for .NET Frameworks' installation files >>%DOWNLOAD_LOGFILE%
  559.   )
  560. )
  561. :SkipDotNet
  562.  
  563. rem *** Download installation files for C++ Runtime Libraries ***
  564. if "%INC_DOTNET%" NEQ "1" goto SkipCPP
  565. if "%SKIP_DL%"=="1" goto SkipCPP
  566. if "%VERIFY_DL%" NEQ "1" goto DownloadCPP
  567. if not exist ..\client\cpp\nul goto DownloadCPP
  568. if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  569. if exist ..\client\md\hashes-cpp.txt (
  570.   echo Verifying integrity of C++ Runtime Libraries' installation files...
  571.   pushd ..\client\md
  572.   ..\bin\%HASHDEEP_EXE% -a -l -vv -k hashes-cpp.txt -r ..\cpp
  573.   if errorlevel 1 (
  574.     popd
  575.     goto IntegrityError
  576.   )
  577.   popd
  578.   echo %DATE% %TIME% - Info: Verified integrity of C++ Runtime Libraries' installation files >>%DOWNLOAD_LOGFILE%
  579. ) else (
  580.   echo Warning: Integrity database ..\client\md\hashes-cpp.txt not found.
  581.   echo %DATE% %TIME% - Warning: Integrity database ..\client\md\hashes-cpp.txt not found >>%DOWNLOAD_LOGFILE%
  582. )
  583. :DownloadCPP
  584. for %%i in (..\client\md\hashes-cpp.txt) do echo _%%~ti | %SystemRoot%\system32\find.exe "_%DATE:~-10%" >nul 2>&1
  585. if not errorlevel 1 (
  586.   echo Skipping download/validation of C++ Runtime Libraries' installation files due to 'same day' rule.
  587.   echo %DATE% %TIME% - Info: Skipped download/validation of C++ Runtime Libraries' installation files due to 'same day' rule >>%DOWNLOAD_LOGFILE%
  588.   goto VerifyCPP
  589. )
  590. echo Downloading/validating installation files for C++ Runtime Libraries...
  591. for %%i in (x64 x86) do (
  592.   for /F "tokens=1,2 delims=," %%j in (..\static\StaticDownloadLinks-cpp-%%i-glb.txt) do (
  593.     if "%%k" NEQ "" (
  594.       if exist ..\client\cpp\%%k (
  595.         echo Renaming file ..\client\cpp\%%k to %%~nxj...
  596.         ren ..\client\cpp\%%k %%~nxj
  597.         echo %DATE% %TIME% - Info: Renamed file ..\client\cpp\%%k to %%~nxj >>%DOWNLOAD_LOGFILE%
  598.       )
  599.     )
  600.     %ARIA_PATH% %ARIA_CMDLINE% -d ..\client\cpp %%j
  601.     if errorlevel 1 (
  602.       if exist ..\client\cpp\%%~nxj del ..\client\cpp\%%~nxj
  603.       echo Warning: Download of %%j failed.
  604.       echo %DATE% %TIME% - Warning: Download of %%j failed >>%DOWNLOAD_LOGFILE%
  605.     )
  606.     if "%%k" NEQ "" (
  607.       if exist ..\client\cpp\%%~nxj (
  608.         echo Renaming file ..\client\cpp\%%~nxj to %%k...
  609.         ren ..\client\cpp\%%~nxj %%k
  610.         echo %DATE% %TIME% - Info: Renamed file ..\client\cpp\%%~nxj to %%k >>%DOWNLOAD_LOGFILE%
  611.       )
  612.     )
  613.   )
  614. )
  615. echo %DATE% %TIME% - Info: Downloaded/validated installation files for C++ Runtime Libraries >>%DOWNLOAD_LOGFILE%
  616. if "%CLEANUP_DL%"=="0" goto VerifyCPP
  617. echo Cleaning up client directory for C++ Runtime Libraries...
  618. for /F %%i in ('dir ..\client\cpp /A:-D /B') do (
  619.   %SystemRoot%\system32\find.exe /I "%%i" ..\static\StaticDownloadLinks-cpp-x64-glb.txt >nul 2>&1
  620.   if errorlevel 1 (
  621.     %SystemRoot%\system32\find.exe /I "%%i" ..\static\StaticDownloadLinks-cpp-x86-glb.txt >nul 2>&1
  622.     if errorlevel 1 (
  623.       del ..\client\cpp\%%i
  624.       echo %DATE% %TIME% - Info: Deleted ..\client\cpp\%%i >>%DOWNLOAD_LOGFILE%
  625.     )
  626.   )
  627. )
  628. echo %DATE% %TIME% - Info: Cleaned up client directory for C++ Runtime Libraries >>%DOWNLOAD_LOGFILE%
  629. :VerifyCPP
  630. if "%VERIFY_DL%"=="1" (
  631.  rem *** Verifying digital file signatures for C++ Runtime Libraries' installation files ***
  632.   if not exist ..\bin\sigcheck.exe goto NoSigCheck
  633.   echo Verifying digital file signatures for C++ Runtime Libraries' installation files...
  634.   ..\bin\sigcheck.exe /accepteula -q -u -v ..\client\cpp >"%TEMP%\sigcheck-cpp.txt"
  635.   for /F "usebackq skip=1 eol=N tokens=1 delims=," %%i in ("%TEMP%\sigcheck-cpp.txt") do (
  636.     del %%i
  637.     echo Warning: Deleted unsigned file %%i.
  638.     echo %DATE% %TIME% - Warning: Deleted unsigned file %%i >>%DOWNLOAD_LOGFILE%
  639.   )
  640.   if exist "%TEMP%\sigcheck-cpp.txt" del "%TEMP%\sigcheck-cpp.txt"
  641.   echo %DATE% %TIME% - Info: Verified digital file signatures for C++ Runtime Libraries' installation files >>%DOWNLOAD_LOGFILE%
  642.   if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  643.   echo Creating integrity database for C++ Runtime Libraries' installation files...
  644.   if not exist ..\client\md\nul md ..\client\md
  645.   pushd ..\client\md
  646.   ..\bin\%HASHDEEP_EXE% -c md5,sha1,sha256 -l -r ..\cpp >hashes-cpp.txt
  647.   if errorlevel 1 (
  648.     popd
  649.     echo Warning: Error creating integrity database ..\client\md\hashes-cpp.txt.
  650.     echo %DATE% %TIME% - Warning: Error creating integrity database ..\client\md\hashes-cpp.txt >>%DOWNLOAD_LOGFILE%
  651.   ) else (
  652.     popd
  653.     echo %DATE% %TIME% - Info: Created integrity database for C++ Runtime Libraries' installation files >>%DOWNLOAD_LOGFILE%
  654.   )
  655. ) else (
  656.   if exist ..\client\md\hashes-cpp.txt (
  657.     del ..\client\md\hashes-cpp.txt
  658.     echo %DATE% %TIME% - Info: Deleted integrity database for C++ Runtime Libraries' installation files >>%DOWNLOAD_LOGFILE%
  659.   )
  660. )
  661. :SkipCPP
  662.  
  663. rem *** Download Microsoft Security Essentials - not required for w2k3 ***
  664. if /i "%1"=="w2k3" goto SkipMSSE
  665. if /i "%1"=="w2k3-x64" goto SkipMSSE
  666. if "%INC_MSSE%" NEQ "1" goto SkipMSSE
  667. if "%SKIP_DL%"=="1" goto SkipMSSE
  668. if "%VERIFY_DL%" NEQ "1" goto DownloadMSSE
  669. if not exist ..\client\msse\nul goto DownloadMSSE
  670. if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  671. if exist ..\client\md\hashes-msse.txt (
  672.   echo Verifying integrity of Microsoft Security Essentials files...
  673.   pushd ..\client\md
  674.   ..\bin\%HASHDEEP_EXE% -a -l -vv -k hashes-msse.txt -r ..\msse
  675.   if errorlevel 1 (
  676.     popd
  677.     goto IntegrityError
  678.   )
  679.   popd
  680.   echo %DATE% %TIME% - Info: Verified integrity of Microsoft Security Essentials files >>%DOWNLOAD_LOGFILE%
  681. ) else (
  682.   echo Warning: Integrity database ..\client\md\hashes-msse.txt not found.
  683.   echo %DATE% %TIME% - Warning: Integrity database ..\client\md\hashes-msse.txt not found >>%DOWNLOAD_LOGFILE%
  684. )
  685. :DownloadMSSE
  686. if exist ..\client\msse\%TARGET_ARCH%-glb\mpam*.exe (
  687.   for %%i in (..\client\msse\%TARGET_ARCH%-glb\mpam*.exe) do echo _%%~ti | %SystemRoot%\system32\find.exe "_%DATE:~-10%" >nul 2>&1
  688.   if not errorlevel 1 (
  689.     echo Skipping download/validation of Microsoft Security Essentials files due to 'same day' rule.
  690.     echo %DATE% %TIME% - Info: Skipped download/validation of Microsoft Security Essentials files due to 'same day' rule >>%DOWNLOAD_LOGFILE%
  691.     goto VerifyMSSE
  692.   )
  693. )
  694. echo Downloading/validating Microsoft Security Essentials files...
  695. copy /Y ..\static\StaticDownloadLinks-msse-%TARGET_ARCH%-glb.txt "%TEMP%\StaticDownloadLinks-msse-%TARGET_ARCH%-glb.txt" >nul
  696. if exist ..\static\custom\StaticDownloadLinks-msse-%TARGET_ARCH%-glb.txt (
  697.   type ..\static\custom\StaticDownloadLinks-msse-%TARGET_ARCH%-glb.txt >>"%TEMP%\StaticDownloadLinks-msse-%TARGET_ARCH%-glb.txt"
  698. )
  699. for /F "usebackq tokens=1,2 delims=," %%i in ("%TEMP%\StaticDownloadLinks-msse-%TARGET_ARCH%-glb.txt") do (
  700.   if "%%j" NEQ "" (
  701.     if exist ..\client\msse\%TARGET_ARCH%-glb\%%j (
  702.       echo Renaming file ..\client\msse\%TARGET_ARCH%-glb\%%j to %%~nxi...
  703.       ren ..\client\msse\%TARGET_ARCH%-glb\%%j %%~nxi
  704.       echo %DATE% %TIME% - Info: Renamed file ..\client\msse\%TARGET_ARCH%-glb\%%j to %%~nxi >>%DOWNLOAD_LOGFILE%
  705.     )
  706.   )
  707.   %ARIA_PATH% %ARIA_CMDLINE% -d ..\client\msse\%TARGET_ARCH%-glb %%i
  708.   if errorlevel 1 (
  709.     if exist ..\client\msse\%TARGET_ARCH%-glb\%%~nxi del ..\client\msse\%TARGET_ARCH%-glb\%%~nxi
  710.     echo Warning: Download of %%i failed.
  711.     echo %DATE% %TIME% - Warning: Download of %%i failed >>%DOWNLOAD_LOGFILE%
  712.   )
  713.   if "%%j" NEQ "" (
  714.     if exist ..\client\msse\%TARGET_ARCH%-glb\%%~nxi (
  715.       echo Renaming file ..\client\msse\%TARGET_ARCH%-glb\%%~nxi to %%j...
  716.       ren ..\client\msse\%TARGET_ARCH%-glb\%%~nxi %%j
  717.       echo %DATE% %TIME% - Info: Renamed file ..\client\msse\%TARGET_ARCH%-glb\%%~nxi to %%j >>%DOWNLOAD_LOGFILE%
  718.     )
  719.   )
  720. )
  721. echo %DATE% %TIME% - Info: Downloaded/validated Microsoft Security Essentials files >>%DOWNLOAD_LOGFILE%
  722. if "%CLEANUP_DL%"=="0" (
  723.   del "%TEMP%\StaticDownloadLinks-msse-%TARGET_ARCH%-glb.txt"
  724.   goto VerifyMSSE
  725. )
  726. echo Cleaning up client directory for Microsoft Security Essentials...
  727. for /F %%i in ('dir ..\client\msse\%TARGET_ARCH%-glb /A:-D /B') do (
  728.   %SystemRoot%\system32\find.exe /I "%%i" "%TEMP%\StaticDownloadLinks-msse-%TARGET_ARCH%-glb.txt" >nul 2>&1
  729.   if errorlevel 1 (
  730.     del ..\client\msse\%TARGET_ARCH%-glb\%%i
  731.     echo %DATE% %TIME% - Info: Deleted ..\client\msse\%TARGET_ARCH%-glb\%%i >>%DOWNLOAD_LOGFILE%
  732.   )
  733. )
  734. del "%TEMP%\StaticDownloadLinks-msse-%TARGET_ARCH%-glb.txt"
  735. echo %DATE% %TIME% - Info: Cleaned up client directory for Microsoft Security Essentials >>%DOWNLOAD_LOGFILE%
  736. :VerifyMSSE
  737. if "%VERIFY_DL%"=="1" (
  738.  rem *** Verifying digital file signatures for Microsoft Security Essentials files ***
  739.   if not exist ..\bin\sigcheck.exe goto NoSigCheck
  740.   echo Verifying digital file signatures for Microsoft Security Essentials files...
  741.   ..\bin\sigcheck.exe /accepteula -q -s -u -v ..\client\msse\%TARGET_ARCH%-glb >"%TEMP%\sigcheck-msse-%TARGET_ARCH%-glb.txt"
  742.   for /F "usebackq skip=1 eol=N tokens=1 delims=," %%i in ("%TEMP%\sigcheck-msse-%TARGET_ARCH%-glb.txt") do (
  743.     del %%i
  744.     echo Warning: Deleted unsigned file %%i.
  745.     echo %DATE% %TIME% - Warning: Deleted unsigned file %%i >>%DOWNLOAD_LOGFILE%
  746.   )
  747.   if exist "%TEMP%\sigcheck-msse-%TARGET_ARCH%-glb.txt" del "%TEMP%\sigcheck-msse-%TARGET_ARCH%-glb.txt"
  748.   echo %DATE% %TIME% - Info: Verified digital file signatures for Microsoft Security Essentials files >>%DOWNLOAD_LOGFILE%
  749.   if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  750.   echo Creating integrity database for Microsoft Security Essentials files...
  751.   if not exist ..\client\md\nul md ..\client\md
  752.   pushd ..\client\md
  753.   ..\bin\%HASHDEEP_EXE% -c md5,sha1,sha256 -l -r ..\msse >hashes-msse.txt
  754.   if errorlevel 1 (
  755.     popd
  756.     echo Warning: Error creating integrity database ..\client\md\hashes-msse.txt.
  757.     echo %DATE% %TIME% - Warning: Error creating integrity database ..\client\md\hashes-msse.txt >>%DOWNLOAD_LOGFILE%
  758.   ) else (
  759.     popd
  760.     echo %DATE% %TIME% - Info: Created integrity database for Microsoft Security Essentials files >>%DOWNLOAD_LOGFILE%
  761.   )
  762. ) else (
  763.   if exist ..\client\md\hashes-msse.txt (
  764.     del ..\client\md\hashes-msse.txt
  765.     echo %DATE% %TIME% - Info: Deleted integrity database for Microsoft Security Essentials files >>%DOWNLOAD_LOGFILE%
  766.   )
  767. )
  768. :SkipMSSE
  769.  
  770. rem *** Download Windows Defender definition files ***
  771. if "%INC_WDDEFS%" NEQ "1" goto SkipWDDefs
  772. if "%SKIP_DL%"=="1" goto SkipWDDefs
  773. if "%VERIFY_DL%" NEQ "1" goto DownloadWDDefs
  774. if not exist ..\client\wddefs\nul goto DownloadWDDefs
  775. if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  776. if exist ..\client\md\hashes-wddefs.txt (
  777.   echo Verifying integrity of Windows Defender definition files...
  778.   pushd ..\client\md
  779.   ..\bin\%HASHDEEP_EXE% -a -l -vv -k hashes-wddefs.txt -r ..\wddefs
  780.   if errorlevel 1 (
  781.     popd
  782.     goto IntegrityError
  783.   )
  784.   popd
  785.   echo %DATE% %TIME% - Info: Verified integrity of Windows Defender definition files >>%DOWNLOAD_LOGFILE%
  786. ) else (
  787.   echo Warning: Integrity database ..\client\md\hashes-wddefs.txt not found.
  788.   echo %DATE% %TIME% - Warning: Integrity database ..\client\md\hashes-wddefs.txt not found >>%DOWNLOAD_LOGFILE%
  789. )
  790. :DownloadWDDefs
  791. if exist ..\client\wddefs\%TARGET_ARCH%-glb\mpas*.exe (
  792.   for %%i in (..\client\wddefs\%TARGET_ARCH%-glb\mpas*.exe) do echo _%%~ti | %SystemRoot%\system32\find.exe "_%DATE:~-10%" >nul 2>&1
  793.   if not errorlevel 1 (
  794.     echo Skipping download/validation of Windows Defender definition files due to 'same day' rule.
  795.     echo %DATE% %TIME% - Info: Skipped download/validation of Windows Defender definition files due to 'same day' rule >>%DOWNLOAD_LOGFILE%
  796.     goto VerifyWDDefs
  797.   )
  798. )
  799. echo Downloading/validating Windows Defender definition files...
  800. %ARIA_PATH% %ARIA_CMDLINE% -d ..\client\wddefs\%TARGET_ARCH%-glb -i ..\static\StaticDownloadLink-wddefs-%TARGET_ARCH%-glb.txt
  801.  
  802. if errorlevel 1 goto DownloadError
  803. echo %DATE% %TIME% - Info: Downloaded/validated Windows Defender definition files >>%DOWNLOAD_LOGFILE%
  804. :VerifyWDDefs
  805. if "%VERIFY_DL%"=="1" (
  806.  rem *** Verifying digital file signatures for Windows Defender definition files ***
  807.   if not exist ..\bin\sigcheck.exe goto NoSigCheck
  808.   echo Verifying digital file signatures for Windows Defender definition files...
  809.   ..\bin\sigcheck.exe /accepteula -q -s -u -v ..\client\wddefs\%TARGET_ARCH%-glb >"%TEMP%\sigcheck-wddefs-%TARGET_ARCH%-glb.txt"
  810.   for /F "usebackq skip=1 eol=N tokens=1 delims=," %%i in ("%TEMP%\sigcheck-wddefs-%TARGET_ARCH%-glb.txt") do (
  811.     del %%i
  812.     echo Warning: Deleted unsigned file %%i.
  813.     echo %DATE% %TIME% - Warning: Deleted unsigned file %%i >>%DOWNLOAD_LOGFILE%
  814.   )
  815.   if exist "%TEMP%\sigcheck-wddefs-%TARGET_ARCH%-glb.txt" del "%TEMP%\sigcheck-wddefs-%TARGET_ARCH%-glb.txt"
  816.   echo %DATE% %TIME% - Info: Verified digital file signatures for Windows Defender definition files >>%DOWNLOAD_LOGFILE%
  817.   if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  818.   echo Creating integrity database for Windows Defender definition files...
  819.   if not exist ..\client\md\nul md ..\client\md
  820.   pushd ..\client\md
  821.   ..\bin\%HASHDEEP_EXE% -c md5,sha1,sha256 -l -r ..\wddefs >hashes-wddefs.txt
  822.   if errorlevel 1 (
  823.     popd
  824.     echo Warning: Error creating integrity database ..\client\md\hashes-wddefs.txt.
  825.     echo %DATE% %TIME% - Warning: Error creating integrity database ..\client\md\hashes-wddefs.txt >>%DOWNLOAD_LOGFILE%
  826.   ) else (
  827.     popd
  828.     echo %DATE% %TIME% - Info: Created integrity database for Windows Defender definition files >>%DOWNLOAD_LOGFILE%
  829.   )
  830. ) else (
  831.   if exist ..\client\md\hashes-wddefs.txt (
  832.     del ..\client\md\hashes-wddefs.txt
  833.     echo %DATE% %TIME% - Info: Deleted integrity database for Windows Defender definition files >>%DOWNLOAD_LOGFILE%
  834.   )
  835. )
  836. :SkipWDDefs
  837.  
  838. rem *** Download the platform specific patches ***
  839. for %%i in (wxp w2k3 w2k3-x64 w60 w60-x64 w61 w61-x64 w62 w62-x64) do (
  840.   if /i "%1"=="%%i" (
  841.     call :DownloadCore win glb x86 %SKIP_PARAM%
  842.     if errorlevel 1 goto Error
  843.   )
  844. )
  845. for %%i in (wxp w2k3) do (
  846.   if /i "%1"=="%%i" (
  847.     call :DownloadCore win %2 %TARGET_ARCH% %SKIP_PARAM%
  848.     if errorlevel 1 goto Error
  849.   )
  850. )
  851. for %%i in (o2k3 o2k7 o2k10) do (
  852.   if /i "%1"=="%%i" (
  853.     call :DownloadCore ofc %2 %TARGET_ARCH% %SKIP_PARAM%
  854.     if errorlevel 1 goto Error
  855.   )
  856. )
  857. for %%i in (wxp w2k3 w2k3-x64 o2k3 o2k7 o2k10) do (
  858.   if /i "%1"=="%%i" (
  859.     call :DownloadCore %1 glb %TARGET_ARCH% %SKIP_PARAM%
  860.     if errorlevel 1 goto Error
  861.     call :DownloadCore %1 %2 %TARGET_ARCH% %SKIP_PARAM%
  862.     if errorlevel 1 goto Error
  863.   )
  864. )
  865. for %%i in (w60 w60-x64 w61 w61-x64 w62 w62-x64 ofc o2k13) do (
  866.   if /i "%1"=="%%i" (
  867.     call :DownloadCore %1 %2 %TARGET_ARCH% %SKIP_PARAM%
  868.     if errorlevel 1 goto Error
  869.   )
  870. )
  871. goto RemindDate
  872.  
  873. :DownloadCore
  874. rem *** Determine update urls for %1 %2 ***
  875. title %~n0 %1 %2 %3 %4 %5 %6 %7 %8 %9
  876. echo.
  877.  
  878. rem *** Verify integrity of existing updates for %1 %2 ***
  879. if "%4"=="/skipdownload" goto SkipStatics
  880. if "%VERIFY_DL%" NEQ "1" goto SkipAudit
  881. if not exist ..\client\%1\%2\nul goto SkipAudit
  882. if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  883. for %%i in (..\client\md\hashes-%1-%2.txt) do if %%~zi==0 del %%i
  884. if exist ..\client\md\hashes-%1-%2.txt (
  885.   echo Verifying integrity of existing updates for %1 %2...
  886.   pushd ..\client\md
  887.   ..\bin\%HASHDEEP_EXE% -a -l -vv -k hashes-%1-%2.txt -r ..\%1\%2
  888.   if errorlevel 1 (
  889.     popd
  890.     goto IntegrityError
  891.   )
  892.   popd
  893.   echo %DATE% %TIME% - Info: Verified integrity of existing updates for %1 %2 >>%DOWNLOAD_LOGFILE%
  894. ) else (
  895.   echo Warning: Integrity database ..\client\md\hashes-%1-%2.txt not found.
  896.   echo %DATE% %TIME% - Warning: Integrity database ..\client\md\hashes-%1-%2.txt not found >>%DOWNLOAD_LOGFILE%
  897. )
  898.  
  899. :SkipAudit
  900. rem *** Determine static update urls for %1 %2 ***
  901. if exist "%TEMP%\StaticDownloadLinks-%1-%2.txt" del "%TEMP%\StaticDownloadLinks-%1-%2.txt"
  902. if exist "%TEMP%\ValidStaticLinks-%1-%2.txt" del "%TEMP%\ValidStaticLinks-%1-%2.txt"
  903. if "%EXC_STATICS%"=="1" goto SkipStatics
  904. echo Determining static update urls for %1 %2...
  905. if exist ..\static\StaticDownloadLinks-%1-%2.txt copy /Y ..\static\StaticDownloadLinks-%1-%2.txt "%TEMP%\StaticDownloadLinks-%1-%2.txt" >nul
  906. if exist ..\static\StaticDownloadLinks-%1-%3-%2.txt copy /Y ..\static\StaticDownloadLinks-%1-%3-%2.txt "%TEMP%\StaticDownloadLinks-%1-%2.txt" >nul
  907. if exist ..\static\custom\StaticDownloadLinks-%1-%2.txt (
  908.   type ..\static\custom\StaticDownloadLinks-%1-%2.txt >>"%TEMP%\StaticDownloadLinks-%1-%2.txt"
  909. )
  910. if exist ..\static\custom\StaticDownloadLinks-%1-%3-%2.txt (
  911.   type ..\static\custom\StaticDownloadLinks-%1-%3-%2.txt >>"%TEMP%\StaticDownloadLinks-%1-%2.txt"
  912. )
  913. if not exist "%TEMP%\StaticDownloadLinks-%1-%2.txt" goto SkipStatics
  914.  
  915. :EvalStatics
  916. if "%EXC_SP%"=="1" (
  917.   %SystemRoot%\system32\findstr.exe /L /I /V /G:..\exclude\ExcludeList-SPs.txt "%TEMP%\StaticDownloadLinks-%1-%2.txt" >"%TEMP%\ValidStaticLinks-%1-%2.txt"
  918.   del "%TEMP%\StaticDownloadLinks-%1-%2.txt"
  919. ) else (
  920.   ren "%TEMP%\StaticDownloadLinks-%1-%2.txt" ValidStaticLinks-%1-%2.txt
  921. )
  922. echo %DATE% %TIME% - Info: Determined static update urls for %1 %2 >>%DOWNLOAD_LOGFILE%
  923.  
  924. :SkipStatics
  925. if exist "%TEMP%\DynamicDownloadLinks-%1-%2.txt" del "%TEMP%\DynamicDownloadLinks-%1-%2.txt"
  926. if exist "%TEMP%\ValidDynamicLinks-%1-%2.txt" del "%TEMP%\ValidDynamicLinks-%1-%2.txt"
  927. if "%4"=="/skipdynamic" (
  928.   echo Skipping unneeded determination of superseded updates.
  929.   echo %DATE% %TIME% - Info: Skipped unneeded determination of superseded updates >>%DOWNLOAD_LOGFILE%
  930.   echo Skipping determination of dynamic update urls for %1 %2 on demand.
  931.   echo %DATE% %TIME% - Info: Skipped determination of dynamic update urls for %1 %2 on demand >>%DOWNLOAD_LOGFILE%
  932.   goto DoDownload
  933. )
  934. if /i "%1"=="o2k13" goto DoDownload
  935. rem *** Extract Microsoft's update catalog file package.xml ***
  936. echo Extracting Microsoft's update catalog file package.xml...
  937. if exist "%TEMP%\package.cab" del "%TEMP%\package.cab"
  938. if exist "%TEMP%\package.xml" del "%TEMP%\package.xml"
  939. %SystemRoot%\system32\expand.exe ..\client\wsus\wsusscn2.cab -F:package.cab "%TEMP%" >nul
  940. %SystemRoot%\system32\expand.exe "%TEMP%\package.cab" "%TEMP%\package.xml" >nul
  941. del "%TEMP%\package.cab"
  942. rem *** Determine superseded updates ***
  943. for %%i in (..\client\wsus\wsusscn2.cab) do echo %%~ai | %SystemRoot%\system32\find.exe /I "a" >nul 2>&1
  944. if not errorlevel 1 (
  945.   if exist ..\exclude\ExcludeList-superseded.txt del ..\exclude\ExcludeList-superseded.txt
  946. )
  947. if exist ..\exclude\ExcludeList-superseded.txt (
  948.   echo Found valid list of superseded updates.
  949.   echo %DATE% %TIME% - Info: Found valid list of superseded updates >>%DOWNLOAD_LOGFILE%
  950.   goto SkipSuperseded
  951. )
  952. echo %TIME% - Determining superseded updates (please be patient, this will take a while)...
  953. %CSCRIPT_PATH% //Nologo //B //E:vbs XSLT.vbs "%TEMP%\package.xml" ..\xslt\ExtractUpdateRevisionIds.xsl "%TEMP%\ValidUpdateRevisionIds.txt"
  954. if errorlevel 1 goto DownloadError
  955. %CSCRIPT_PATH% //Nologo //B //E:vbs XSLT.vbs "%TEMP%\package.xml" ..\xslt\ExtractSupersedingRevisionIds.xsl "%TEMP%\SupersedingRevisionIds.txt"
  956. if errorlevel 1 goto DownloadError
  957. %SystemRoot%\system32\findstr.exe /L /G:"%TEMP%\SupersedingRevisionIds.txt" "%TEMP%\ValidUpdateRevisionIds.txt" >"%TEMP%\ValidSupersedingRevisionIds.txt"
  958. del "%TEMP%\ValidUpdateRevisionIds.txt"
  959. del "%TEMP%\SupersedingRevisionIds.txt"
  960. %CSCRIPT_PATH% //Nologo //B //E:vbs XSLT.vbs "%TEMP%\package.xml" ..\xslt\ExtractSupersededUpdateRelations.xsl "%TEMP%\SupersededUpdateRelations.txt"
  961. if errorlevel 1 goto DownloadError
  962. %SystemRoot%\system32\findstr.exe /L /G:"%TEMP%\ValidSupersedingRevisionIds.txt" "%TEMP%\SupersededUpdateRelations.txt" >"%TEMP%\ValidSupersededUpdateRelations.txt"
  963. del "%TEMP%\SupersededUpdateRelations.txt"
  964. del "%TEMP%\ValidSupersedingRevisionIds.txt"
  965. %CSCRIPT_PATH% //Nologo //B //E:vbs XSLT.vbs "%TEMP%\package.xml" ..\xslt\ExtractBundledUpdateRelationsAndFileIds.xsl "%TEMP%\BundledUpdateRelationsAndFileIds.txt"
  966. if errorlevel 1 goto DownloadError
  967. %CSCRIPT_PATH% //Nologo //B //E:vbs ExtractIdsAndFileNames.vbs "%TEMP%\ValidSupersededUpdateRelations.txt" "%TEMP%\ValidSupersededRevisionIds.txt" /firstonly
  968. del "%TEMP%\ValidSupersededUpdateRelations.txt"
  969. %SystemRoot%\system32\findstr.exe /L /G:"%TEMP%\ValidSupersededRevisionIds.txt" "%TEMP%\BundledUpdateRelationsAndFileIds.txt" >"%TEMP%\SupersededRevisionAndFileIds.txt"
  970. del "%TEMP%\ValidSupersededRevisionIds.txt"
  971. del "%TEMP%\BundledUpdateRelationsAndFileIds.txt"
  972. %CSCRIPT_PATH% //Nologo //B //E:vbs ExtractIdsAndFileNames.vbs "%TEMP%\SupersededRevisionAndFileIds.txt" "%TEMP%\SupersededFileIds.txt" /secondonly
  973. del "%TEMP%\SupersededRevisionAndFileIds.txt"
  974. %SystemRoot%\system32\sort.exe "%TEMP%\SupersededFileIds.txt" /O "%TEMP%\SupersededFileIdsSorted.txt"
  975. del "%TEMP%\SupersededFileIds.txt"
  976. %CSCRIPT_PATH% //Nologo //B //E:vbs ExtractUniqueFromSorted.vbs "%TEMP%\SupersededFileIdsSorted.txt" "%TEMP%\SupersededFileIdsUnique.txt"
  977. del "%TEMP%\SupersededFileIdsSorted.txt"
  978. %CSCRIPT_PATH% //Nologo //B //E:vbs XSLT.vbs "%TEMP%\package.xml" ..\xslt\ExtractUpdateCabExeIdsAndLocations.xsl "%TEMP%\UpdateCabExeIdsAndLocations.txt"
  979. if errorlevel 1 goto DownloadError
  980. %SystemRoot%\system32\findstr.exe /B /L /G:"%TEMP%\SupersededFileIdsUnique.txt" "%TEMP%\UpdateCabExeIdsAndLocations.txt" >"%TEMP%\SupersededCabExeIdsAndLocations.txt"
  981. del "%TEMP%\UpdateCabExeIdsAndLocations.txt"
  982. del "%TEMP%\SupersededFileIdsUnique.txt"
  983. %CSCRIPT_PATH% //Nologo //B //E:vbs ExtractIdsAndFileNames.vbs "%TEMP%\SupersededCabExeIdsAndLocations.txt" "%TEMP%\ExcludeList-superseded-all.txt" /noids
  984. del "%TEMP%\SupersededCabExeIdsAndLocations.txt"
  985. %ARIA_PATH% %ARIA_CMDLINE% -d ..\exclude http://download.wsusoffline.net/ExcludeList-superseded-exclude.txt
  986. if exist ..\exclude\ExcludeList-superseded-exclude.txt copy /Y ..\exclude\ExcludeList-superseded-exclude.txt "%TEMP%\ExcludeList-superseded-exclude.txt" >nul
  987. if exist ..\exclude\custom\ExcludeList-superseded-exclude.txt (
  988.   type ..\exclude\custom\ExcludeList-superseded-exclude.txt >>"%TEMP%\ExcludeList-superseded-exclude.txt"
  989. )
  990. %SystemRoot%\system32\findstr.exe /L /I /V /G:"%TEMP%\ExcludeList-superseded-exclude.txt" "%TEMP%\ExcludeList-superseded-all.txt" >..\exclude\ExcludeList-superseded.txt
  991. del "%TEMP%\ExcludeList-superseded-exclude.txt"
  992. del "%TEMP%\ExcludeList-superseded-all.txt"
  993. %SystemRoot%\system32\attrib.exe -A ..\client\wsus\wsusscn2.cab
  994. echo %TIME% - Done.
  995. echo %DATE% %TIME% - Info: Determined superseded updates >>%DOWNLOAD_LOGFILE%
  996. :SkipSuperseded
  997. for %%i in (dotnet win wxp w2k3 w2k3-x64 w60 w60-x64 w61 w61-x64 w62 w62-x64) do (if /i "%1"=="%%i" goto DetermineWindows)
  998. for %%i in (ofc) do (if /i "%1"=="%%i" goto DetermineOffice)
  999. del "%TEMP%\package.xml"
  1000. goto DoDownload
  1001.  
  1002. :DetermineWindows
  1003. rem *** Determine dynamic update urls for %1 %2 ***
  1004. echo %TIME% - Determining dynamic update urls for %1 %2...
  1005. if exist ..\xslt\ExtractDownloadLinks-%1-%2.xsl (
  1006.   %CSCRIPT_PATH% //Nologo //B //E:vbs XSLT.vbs "%TEMP%\package.xml" ..\xslt\ExtractDownloadLinks-%1-%2.xsl "%TEMP%\DynamicDownloadLinks-%1-%2.txt"
  1007.   if errorlevel 1 goto DownloadError
  1008. )
  1009. if exist ..\xslt\ExtractDownloadLinks-%1-%3-%2.xsl (
  1010.   %CSCRIPT_PATH% //Nologo //B //E:vbs XSLT.vbs "%TEMP%\package.xml" ..\xslt\ExtractDownloadLinks-%1-%3-%2.xsl "%TEMP%\DynamicDownloadLinks-%1-%2.txt"
  1011.   if errorlevel 1 goto DownloadError
  1012. )
  1013. del "%TEMP%\package.xml"
  1014.  
  1015. if not exist "%TEMP%\DynamicDownloadLinks-%1-%2.txt" goto DoDownload
  1016.  
  1017. if exist "%TEMP%\ExcludeList-%1.txt" del "%TEMP%\ExcludeList-%1.txt"
  1018. if exist ..\exclude\ExcludeList-%1.txt copy /Y ..\exclude\ExcludeList-%1.txt "%TEMP%\ExcludeList-%1.txt" >nul
  1019. if exist ..\exclude\custom\ExcludeList-%1.txt (
  1020.   type ..\exclude\custom\ExcludeList-%1.txt >>"%TEMP%\ExcludeList-%1.txt"
  1021. )
  1022. if exist "%TEMP%\ExcludeList-%1.txt" goto ExcludeWindows
  1023. if exist ..\exclude\ExcludeList-%1-%3.txt copy /Y ..\exclude\ExcludeList-%1-%3.txt "%TEMP%\ExcludeList-%1.txt" >nul
  1024. if exist ..\exclude\custom\ExcludeList-%1-%3.txt (
  1025.   type ..\exclude\custom\ExcludeList-%1-%3.txt >>"%TEMP%\ExcludeList-%1.txt"
  1026. )
  1027. :ExcludeWindows
  1028. if exist ..\exclude\ExcludeList-superseded.txt (
  1029.   type ..\exclude\ExcludeList-superseded.txt >>"%TEMP%\ExcludeList-%1.txt"
  1030. )
  1031. %SystemRoot%\system32\findstr.exe /L /I /V /G:"%TEMP%\ExcludeList-%1.txt" "%TEMP%\DynamicDownloadLinks-%1-%2.txt" >>"%TEMP%\ValidDynamicLinks-%1-%2.txt"
  1032. if not exist "%TEMP%\ValidDynamicLinks-%1-%2.txt" ren "%TEMP%\DynamicDownloadLinks-%1-%2.txt" ValidDynamicLinks-%1-%2.txt
  1033. if exist "%TEMP%\ExcludeList-%1.txt" del "%TEMP%\ExcludeList-%1.txt"
  1034. if exist "%TEMP%\DynamicDownloadLinks-%1-%2.txt" del "%TEMP%\DynamicDownloadLinks-%1-%2.txt"
  1035. echo %TIME% - Done.
  1036. echo %DATE% %TIME% - Info: Determined dynamic update urls for %1 %2 >>%DOWNLOAD_LOGFILE%
  1037. goto DoDownload
  1038.  
  1039. :DetermineOffice
  1040. rem *** Determine dynamic update urls for %1 %2 ***
  1041. echo %TIME% - Determining dynamic update urls for %1 %2 (please be patient, this will take a while)...
  1042. %CSCRIPT_PATH% //Nologo //B //E:vbs XSLT.vbs "%TEMP%\package.xml" ..\xslt\ExtractUpdateCategoriesAndFileIds.xsl "%TEMP%\UpdateCategoriesAndFileIds.txt"
  1043. if errorlevel 1 goto DownloadError
  1044. %CSCRIPT_PATH% //Nologo //B //E:vbs XSLT.vbs "%TEMP%\package.xml" ..\xslt\ExtractUpdateCabExeIdsAndLocations.xsl "%TEMP%\UpdateCabExeIdsAndLocations.txt"
  1045. if errorlevel 1 goto DownloadError
  1046. del "%TEMP%\package.xml"
  1047.  
  1048. if exist "%TEMP%\OfficeUpdateAndFileIds.txt" del "%TEMP%\OfficeUpdateAndFileIds.txt"
  1049. if exist "%TEMP%\OfficeFileIds.txt" del "%TEMP%\OfficeFileIds.txt"
  1050. set UPDATE_ID=
  1051. set UPDATE_CATEGORY=
  1052. set UPDATE_LANGUAGES=
  1053. for /F "usebackq tokens=1,2 delims=;" %%i in ("%TEMP%\UpdateCategoriesAndFileIds.txt") do (
  1054.   if "%%j"=="" (
  1055.     if "!UPDATE_CATEGORY!"=="477b856e-65c4-4473-b621-a8b230bb70d9" (
  1056.       for /F "tokens=1-3 delims=," %%k in ("%%i") do (
  1057.         if "%%l" NEQ "" (
  1058.           if /i "%2"=="glb" (
  1059.             if "!UPDATE_LANGUAGES!_%%m"=="_" (
  1060.               echo !UPDATE_ID!,%%l>>"%TEMP%\OfficeUpdateAndFileIds.txt"
  1061.               echo %%l>>"%TEMP%\OfficeFileIds.txt"
  1062.             )
  1063.             if "!UPDATE_LANGUAGES!_%%m"=="en_en" (
  1064.               echo !UPDATE_ID!,%%l>>"%TEMP%\OfficeUpdateAndFileIds.txt"
  1065.               echo %%l>>"%TEMP%\OfficeFileIds.txt"
  1066.             )
  1067.           ) else (
  1068.             if "%%m"=="%LANG_SHORT%" (
  1069.               echo !UPDATE_ID!,%%l>>"%TEMP%\OfficeUpdateAndFileIds.txt"
  1070.               echo %%l>>"%TEMP%\OfficeFileIds.txt"
  1071.             )
  1072.           )
  1073.         )
  1074.       )
  1075.     )
  1076.   ) else (
  1077.     for /F "tokens=1 delims=," %%k in ("%%i") do (
  1078.       set UPDATE_ID=%%k
  1079.     )
  1080.     for /F "tokens=1* delims=," %%k in ("%%j") do (
  1081.       set UPDATE_CATEGORY=%%k
  1082.       set UPDATE_LANGUAGES=%%l
  1083.     )
  1084.   )
  1085. )
  1086. set UPDATE_ID=
  1087. set UPDATE_CATEGORY=
  1088. set UPDATE_LANGUAGES=
  1089. del "%TEMP%\UpdateCategoriesAndFileIds.txt"
  1090.  
  1091. %SystemRoot%\system32\sort.exe "%TEMP%\OfficeFileIds.txt" /O "%TEMP%\OfficeFileIdsSortedForward.txt"
  1092. %SystemRoot%\system32\sort.exe /R "%TEMP%\OfficeFileIds.txt" /O "%TEMP%\OfficeFileIdsSortedReverse.txt"
  1093. del "%TEMP%\OfficeFileIds.txt"
  1094. %CSCRIPT_PATH% //Nologo //B //E:vbs ExtractUniqueFromSorted.vbs "%TEMP%\OfficeFileIdsSortedForward.txt" "%TEMP%\OfficeFileIdsUniqueForward.txt"
  1095. del "%TEMP%\OfficeFileIdsSortedForward.txt"
  1096. %CSCRIPT_PATH% //Nologo //B //E:vbs ExtractUniqueFromSorted.vbs "%TEMP%\OfficeFileIdsSortedReverse.txt" "%TEMP%\OfficeFileIdsUniqueReverse.txt"
  1097. del "%TEMP%\OfficeFileIdsSortedReverse.txt"
  1098. %SystemRoot%\system32\findstr.exe /B /L /G:"%TEMP%\OfficeFileIdsUniqueForward.txt" "%TEMP%\UpdateCabExeIdsAndLocations.txt" >"%TEMP%\OfficeUpdateCabExeIdsAndLocationsDouble.txt"
  1099. del "%TEMP%\OfficeFileIdsUniqueForward.txt"
  1100. %SystemRoot%\system32\findstr.exe /B /L /G:"%TEMP%\OfficeFileIdsUniqueReverse.txt" "%TEMP%\UpdateCabExeIdsAndLocations.txt" >>"%TEMP%\OfficeUpdateCabExeIdsAndLocationsDouble.txt"
  1101. del "%TEMP%\OfficeFileIdsUniqueReverse.txt"
  1102. del "%TEMP%\UpdateCabExeIdsAndLocations.txt"
  1103. %SystemRoot%\system32\sort.exe "%TEMP%\OfficeUpdateCabExeIdsAndLocationsDouble.txt" /O "%TEMP%\OfficeUpdateCabExeIdsAndLocationsSorted.txt"
  1104. del "%TEMP%\OfficeUpdateCabExeIdsAndLocationsDouble.txt"
  1105. %CSCRIPT_PATH% //Nologo //B //E:vbs ExtractUniqueFromSorted.vbs "%TEMP%\OfficeUpdateCabExeIdsAndLocationsSorted.txt" "%TEMP%\OfficeUpdateCabExeIdsAndLocations.txt"
  1106. del "%TEMP%\OfficeUpdateCabExeIdsAndLocationsSorted.txt"
  1107.  
  1108. if exist "%TEMP%\DynamicDownloadLinks-%1-%2.txt" del "%TEMP%\DynamicDownloadLinks-%1-%2.txt"
  1109. if exist "%TEMP%\UpdateTableURL-%1-%2.csv" del "%TEMP%\UpdateTableURL-%1-%2.csv"
  1110. for /F "usebackq tokens=1,2 delims=," %%i in ("%TEMP%\OfficeUpdateCabExeIdsAndLocations.txt") do (
  1111.   for /F "usebackq tokens=1,2 delims=," %%k in ("%TEMP%\OfficeUpdateAndFileIds.txt") do (
  1112.     if /i "%%l"=="%%i" (
  1113.       echo %%j>>"%TEMP%\DynamicDownloadLinks-%1-%2.txt"
  1114.       echo %%k,%%j>>"%TEMP%\UpdateTableURL-%1-%2.csv"
  1115.     )
  1116.   )
  1117. )
  1118. del "%TEMP%\OfficeUpdateAndFileIds.txt"
  1119. del "%TEMP%\OfficeUpdateCabExeIdsAndLocations.txt"
  1120. if not exist ..\client\ofc\nul md ..\client\ofc
  1121. %CSCRIPT_PATH% //Nologo //B //E:vbs ExtractIdsAndFileNames.vbs "%TEMP%\UpdateTableURL-%1-%2.csv" ..\client\ofc\UpdateTable-%1-%2.csv
  1122. del "%TEMP%\UpdateTableURL-%1-%2.csv"
  1123.  
  1124. :ExcludeOffice
  1125. if exist "%TEMP%\ExcludeList-%1.txt" del "%TEMP%\ExcludeList-%1.txt"
  1126. if exist ..\exclude\ExcludeList-%1.txt copy /Y ..\exclude\ExcludeList-%1.txt "%TEMP%\ExcludeList-%1.txt" >nul
  1127. if exist ..\exclude\custom\ExcludeList-%1.txt (
  1128.   type ..\exclude\custom\ExcludeList-%1.txt >>"%TEMP%\ExcludeList-%1.txt"
  1129. )
  1130. if exist ..\exclude\ExcludeList-superseded.txt (
  1131.   type ..\exclude\ExcludeList-superseded.txt >>"%TEMP%\ExcludeList-%1.txt"
  1132. )
  1133. %SystemRoot%\system32\findstr.exe /L /I /V /G:"%TEMP%\ExcludeList-%1.txt" "%TEMP%\DynamicDownloadLinks-%1-%2.txt" >>"%TEMP%\ValidDynamicLinks-%1-%2.txt"
  1134. if not exist "%TEMP%\ValidDynamicLinks-%1-%2.txt" ren "%TEMP%\DynamicDownloadLinks-%1-%2.txt" ValidDynamicLinks-%1-%2.txt
  1135. if exist "%TEMP%\ExcludeList-%1.txt" del "%TEMP%\ExcludeList-%1.txt"
  1136. if exist "%TEMP%\DynamicDownloadLinks-%1-%2.txt" del "%TEMP%\DynamicDownloadLinks-%1-%2.txt"
  1137. echo %TIME% - Done.
  1138. echo %DATE% %TIME% - Info: Determined dynamic update urls for %1 %2 >>%DOWNLOAD_LOGFILE%
  1139.  
  1140. :DoDownload
  1141. rem *** Download updates for %1 %2 ***
  1142. if "%4"=="/skipdownload" (
  1143.   echo Skipping download/validation of updates for %1 %2 on demand.
  1144.   echo %DATE% %TIME% - Info: Skipped download/validation of updates for %1 %2 on demand >>%DOWNLOAD_LOGFILE%
  1145.   goto EndDownload
  1146. )
  1147. if not exist "%TEMP%\ValidStaticLinks-%1-%2.txt" goto DownloadDynamicUpdates
  1148. echo Downloading/validating statically defined updates for %1 %2...
  1149. set LINES_COUNT=0
  1150. for /F "tokens=1* delims=:" %%i in ('%SystemRoot%\system32\findstr.exe /N $ "%TEMP%\ValidStaticLinks-%1-%2.txt"') do set LINES_COUNT=%%i
  1151. for /F "tokens=1* delims=:" %%i in ('%SystemRoot%\system32\findstr.exe /N $ "%TEMP%\ValidStaticLinks-%1-%2.txt"') do (
  1152.   echo Downloading/validating update %%i of %LINES_COUNT%...
  1153.   for /F "tokens=1,2 delims=," %%k in ("%%j") do (
  1154.     if "%%l" NEQ "" (
  1155.       if exist ..\client\%1\%2\%%l (
  1156.         echo Renaming file ..\client\%1\%2\%%l to %%~nxk...
  1157.         ren ..\client\%1\%2\%%l %%~nxk
  1158.         echo %DATE% %TIME% - Info: Renamed file ..\client\%1\%2\%%l to %%~nxk >>%DOWNLOAD_LOGFILE%
  1159.       )
  1160.     )
  1161.     %ARIA_PATH% %ARIA_CMDLINE% -d ..\client\%1\%2 %%k
  1162.     if errorlevel 1 (
  1163.       if exist ..\client\%1\%2\%%~nxk del ..\client\%1\%2\%%~nxk
  1164.       echo Warning: Download of %%k failed.
  1165.       echo %DATE% %TIME% - Warning: Download of %%k failed >>%DOWNLOAD_LOGFILE%
  1166.     )
  1167.     if "%%l" NEQ "" (
  1168.       if exist ..\client\%1\%2\%%~nxk (
  1169.         echo Renaming file ..\client\%1\%2\%%~nxk to %%l...
  1170.         ren ..\client\%1\%2\%%~nxk %%l
  1171.         echo %DATE% %TIME% - Info: Renamed file ..\client\%1\%2\%%~nxk to %%l >>%DOWNLOAD_LOGFILE%
  1172.       )
  1173.     )
  1174.   )
  1175. )
  1176. echo %DATE% %TIME% - Info: Downloaded/validated %LINES_COUNT% statically defined updates for %1 %2 >>%DOWNLOAD_LOGFILE%
  1177.  
  1178. :DownloadDynamicUpdates
  1179. if not exist "%TEMP%\ValidDynamicLinks-%1-%2.txt" goto CleanupDownload
  1180. echo Downloading/validating dynamically determined updates for %1 %2...
  1181. set LINES_COUNT=0
  1182. for /F "tokens=1* delims=:" %%i in ('%SystemRoot%\system32\findstr.exe /N $ "%TEMP%\ValidDynamicLinks-%1-%2.txt"') do set LINES_COUNT=%%i
  1183. if "%WSUS_URL%"=="" (
  1184.   for /F "tokens=1* delims=:" %%i in ('%SystemRoot%\system32\findstr.exe /N $ "%TEMP%\ValidDynamicLinks-%1-%2.txt"') do (
  1185.     echo Downloading/validating update %%i of %LINES_COUNT%...
  1186.     %ARIA_PATH% %ARIA_CMDLINE% -d ..\client\%1\%2 %%j
  1187.     if errorlevel 1 (
  1188.       echo Warning: Download of %%j failed.
  1189.       echo %DATE% %TIME% - Warning: Download of %%j failed >>%DOWNLOAD_LOGFILE%
  1190.     )
  1191.   )
  1192. ) else (
  1193.   echo Creating WSUS download table for %1 %2...
  1194.   %CSCRIPT_PATH% //Nologo //B //E:vbs CreateDownloadTable.vbs "%TEMP%\ValidDynamicLinks-%1-%2.txt" %WSUS_URL%
  1195.   if errorlevel 1 goto DownloadError
  1196.   echo %DATE% %TIME% - Info: Created WSUS download table for %1 %2 >>%DOWNLOAD_LOGFILE%
  1197.   for /F "tokens=1* delims=:" %%i in ('%SystemRoot%\system32\findstr.exe /N $ "%TEMP%\ValidDynamicLinks-%1-%2.csv"') do (
  1198.     echo Downloading/validating update %%i of %LINES_COUNT%...
  1199.     for /F "tokens=1-3 delims=," %%k in ("%%j") do (
  1200.       if "%%m"=="" (
  1201.         %ARIA_PATH% %ARIA_CMDLINE% -d ..\client\%1\%2 %%l
  1202.         if errorlevel 1 (
  1203.           echo Warning: Download of %%j failed.
  1204.           echo %DATE% %TIME% - Warning: Download of %%j failed >>%DOWNLOAD_LOGFILE%
  1205.         )
  1206.       ) else (
  1207.         if exist ..\client\%1\%2\%%k (
  1208.           echo Renaming file ..\client\%1\%2\%%k to %%~nxl...
  1209.           ren ..\client\%1\%2\%%k %%~nxl
  1210.           echo %DATE% %TIME% - Info: Renamed file ..\client\%1\%2\%%k to %%~nxl >>%DOWNLOAD_LOGFILE%
  1211.         )
  1212.         if "%WSUS_BY_PROXY%"=="1" (
  1213.           %ARIA_PATH% %ARIA_CMDLINE% -d ..\client\%1\%2 %%l
  1214.         ) else (
  1215.           %ARIA_PATH% %ARIA_CMDLINE% -d ..\client\%1\%2 %%l --all-proxy=""
  1216.         )
  1217.         if errorlevel 1 (
  1218.           if exist ..\client\%1\%2\%%~nxl (
  1219.             echo Renaming file ..\client\%1\%2\%%~nxl to %%k...
  1220.             ren ..\client\%1\%2\%%~nxl %%k
  1221.             echo %DATE% %TIME% - Info: Renamed file ..\client\%1\%2\%%~nxl to %%k >>%DOWNLOAD_LOGFILE%
  1222.           )
  1223.           if "%WSUS_ONLY%"=="1" (
  1224.             echo Warning: Download of %%l ^(%%k^) failed.
  1225.             echo %DATE% %TIME% - Warning: Download of %%l ^(%%k^) failed >>%DOWNLOAD_LOGFILE%
  1226.           ) else (
  1227.             %ARIA_PATH% %ARIA_CMDLINE% -d ..\client\%1\%2 %%m
  1228.             if errorlevel 1 (
  1229.               echo Warning: Download of %%m failed.
  1230.               echo %DATE% %TIME% - Warning: Download of %%m failed >>%DOWNLOAD_LOGFILE%
  1231.             )
  1232.           )
  1233.         ) else (
  1234.           if exist ..\client\%1\%2\%%~nxl (
  1235.             echo Renaming file ..\client\%1\%2\%%~nxl to %%k...
  1236.             ren ..\client\%1\%2\%%~nxl %%k
  1237.             echo %DATE% %TIME% - Info: Renamed file ..\client\%1\%2\%%~nxl to %%k >>%DOWNLOAD_LOGFILE%
  1238.           )
  1239.         )
  1240.       )
  1241.     )
  1242.   )
  1243. )
  1244. echo %DATE% %TIME% - Info: Downloaded/validated %LINES_COUNT% dynamically determined updates for %1 %2 >>%DOWNLOAD_LOGFILE%
  1245.  
  1246. :CleanupDownload
  1247. rem *** Clean up client directory for %1 %2 ***
  1248. if not exist ..\client\%1\%2\nul goto RemoveHashes
  1249. if "%CLEANUP_DL%"=="0" goto VerifyDownload
  1250. echo Cleaning up client directory for %1 %2...
  1251. if exist "%TEMP%\ValidLinks-%1-%2.txt" del "%TEMP%\ValidLinks-%1-%2.txt"
  1252. if exist "%TEMP%\ValidStaticLinks-%1-%2.txt" (
  1253.   type "%TEMP%\ValidStaticLinks-%1-%2.txt" >>"%TEMP%\ValidLinks-%1-%2.txt"
  1254. )
  1255. if exist "%TEMP%\ValidDynamicLinks-%1-%2.txt" (
  1256.   type "%TEMP%\ValidDynamicLinks-%1-%2.txt" >>"%TEMP%\ValidLinks-%1-%2.txt"
  1257. )
  1258. for /F %%i in ('dir ..\client\%1\%2 /A:-D /B') do (
  1259.   if exist "%TEMP%\ValidLinks-%1-%2.txt" (
  1260.     %SystemRoot%\system32\find.exe /I "%%i" "%TEMP%\ValidLinks-%1-%2.txt" >nul 2>&1
  1261.     if errorlevel 1 (
  1262.       del ..\client\%1\%2\%%i
  1263.       echo %DATE% %TIME% - Info: Deleted ..\client\%1\%2\%%i >>%DOWNLOAD_LOGFILE%
  1264.     )
  1265.   ) else (
  1266.     del ..\client\%1\%2\%%i
  1267.     echo %DATE% %TIME% - Info: Deleted ..\client\%1\%2\%%i >>%DOWNLOAD_LOGFILE%
  1268.   )
  1269. )
  1270. if exist "%TEMP%\ValidLinks-%1-%2.txt" del "%TEMP%\ValidLinks-%1-%2.txt"
  1271. dir ..\client\%1\%2 /A:-D >nul 2>&1
  1272. if errorlevel 1 rd ..\client\%1\%2
  1273. echo %DATE% %TIME% - Info: Cleaned up client directory for %1 %2 >>%DOWNLOAD_LOGFILE%
  1274.  
  1275. :VerifyDownload
  1276. if not exist ..\client\%1\%2\nul goto RemoveHashes
  1277. rem *** Remove NTFS alternate data streams for %1 %2 ***
  1278. if exist ..\bin\streams.exe (
  1279.   ..\bin\streams.exe /accepteula -s ..\client\%1\%2\*.* >nul 2>&1
  1280.   if errorlevel 1 (
  1281.     echo %DATE% %TIME% - Info: File system does not support streams >>%DOWNLOAD_LOGFILE%
  1282.   ) else (
  1283.     echo Removing NTFS alternate data streams for %1 %2...
  1284.     ..\bin\streams.exe /accepteula -s -d ..\client\%1\%2\*.* >nul 2>&1
  1285.     if errorlevel 1 (
  1286.       echo Warning: Unable to remove NTFS alternate data streams for %1 %2.
  1287.       echo %DATE% %TIME% - Warning: Unable to remove NTFS alternate data streams for %1 %2 >>%DOWNLOAD_LOGFILE%
  1288.     ) else (
  1289.       echo %DATE% %TIME% - Info: Removed NTFS alternate data streams for %1 %2 >>%DOWNLOAD_LOGFILE%
  1290.     )
  1291.   )
  1292. ) else (
  1293.   echo Warning: Sysinternals' NTFS alternate data stream handling tool ..\bin\streams.exe not found.
  1294.   echo %DATE% %TIME% - Warning: Sysinternals' NTFS alternate data stream handling tool ..\bin\streams.exe not found >>%DOWNLOAD_LOGFILE%
  1295. )
  1296. if "%VERIFY_DL%" NEQ "1" goto RemoveHashes
  1297. rem *** Verifying digital file signatures for %1 %2 ***
  1298. if not exist ..\bin\sigcheck.exe goto NoSigCheck
  1299. echo Verifying digital file signatures for %1 %2...
  1300. ..\bin\sigcheck.exe /accepteula -q -s -u -v ..\client\%1\%2 >"%TEMP%\sigcheck-%1-%2.txt"
  1301. for /F "usebackq skip=1 eol=N tokens=1 delims=," %%i in ("%TEMP%\sigcheck-%1-%2.txt") do (
  1302.   del %%i
  1303.   echo Warning: Deleted unsigned file %%i.
  1304.   echo %DATE% %TIME% - Warning: Deleted unsigned file %%i >>%DOWNLOAD_LOGFILE%
  1305. )
  1306. if exist "%TEMP%\sigcheck-%1-%2.txt" del "%TEMP%\sigcheck-%1-%2.txt"
  1307. echo %DATE% %TIME% - Info: Verified digital file signatures for %1 %2 >>%DOWNLOAD_LOGFILE%
  1308. rem *** Create integrity database for %1 %2 ***
  1309. if not exist ..\client\bin\%HASHDEEP_EXE% goto NoHashDeep
  1310. echo Creating integrity database for %1 %2...
  1311. if not exist ..\client\md\nul md ..\client\md
  1312. pushd ..\client\md
  1313. ..\bin\%HASHDEEP_EXE% -c md5,sha1,sha256 -l -r ..\%1\%2 >hashes-%1-%2.txt
  1314. if errorlevel 1 (
  1315.   popd
  1316.   echo Warning: Error creating integrity database ..\client\md\hashes-%1-%2.txt.
  1317.   echo %DATE% %TIME% - Warning: Error creating integrity database ..\client\md\hashes-%1-%2.txt >>%DOWNLOAD_LOGFILE%
  1318. ) else (
  1319.   popd
  1320.   for %%i in (..\client\md\hashes-%1-%2.txt) do (
  1321.     if %%~zi==0 (
  1322.       del %%i
  1323.       echo %DATE% %TIME% - Info: Deleted zero size integrity database for %1 %2 >>%DOWNLOAD_LOGFILE%
  1324.     ) else (
  1325.       echo %DATE% %TIME% - Info: Created integrity database for %1 %2 >>%DOWNLOAD_LOGFILE%
  1326.     )
  1327.   )
  1328. )
  1329. if not exist ..\client\md\hashes-%1-%2.txt goto EndDownload
  1330. %SystemRoot%\system32\findstr.exe _[A-Fa-f0-9]*\.[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]$ ..\client\md\hashes-%1-%2.txt >"%TEMP%\sha1-%1-%2.txt"
  1331. for /F "usebackq tokens=3,5 delims=," %%i in ("%TEMP%\sha1-%1-%2.txt") do (
  1332.   for /F "tokens=2 delims=_" %%k in ("%%j") do (
  1333.     for /F "tokens=1 delims=." %%l in ("%%k") do (
  1334.       if "%%l" NEQ "%%i" (
  1335.         pushd ..\client\md
  1336.         del %%j
  1337.         ren hashes-%1-%2.txt hashes-%1-%2.bak
  1338.         %SystemRoot%\system32\findstr.exe /L /I /V "%%j" hashes-%1-%2.bak >hashes-%1-%2.txt
  1339.         del hashes-%1-%2.bak
  1340.         popd
  1341.         echo Warning: Deleted file %%j due to mismatching SHA-1 message digest ^(%%i^).
  1342.         echo %DATE% %TIME% - Warning: Deleted file %%j due to mismatching SHA-1 message digest ^(%%i^) >>%DOWNLOAD_LOGFILE%
  1343.       )
  1344.     )
  1345.   )
  1346. )
  1347. del "%TEMP%\sha1-%1-%2.txt"
  1348. goto EndDownload
  1349.  
  1350. :RemoveHashes
  1351. if exist ..\client\md\hashes-%1-%2.txt (
  1352.   del ..\client\md\hashes-%1-%2.txt
  1353.   echo %DATE% %TIME% - Info: Deleted integrity database for %1 %2 >>%DOWNLOAD_LOGFILE%
  1354. )
  1355. :EndDownload
  1356. if exist "%TEMP%\ValidStaticLinks-%1-%2.txt" del "%TEMP%\ValidStaticLinks-%1-%2.txt"
  1357. if exist "%TEMP%\ValidDynamicLinks-%1-%2.csv" del "%TEMP%\ValidDynamicLinks-%1-%2.csv"
  1358. if "%4"=="/skipdownload" (
  1359.   for %%i in (win wxp w2k3 w60 w61 w62) do (
  1360.     if /i "%1"=="%%i" (
  1361.       if exist "%TEMP%\ValidDynamicLinks-%1-%2.txt" move /Y "%TEMP%\ValidDynamicLinks-%1-%2.txt" ..\static\custom\StaticDownloadLinks-%1-%3-%2.txt >nul
  1362.     )
  1363.   )
  1364.   if exist "%TEMP%\ValidDynamicLinks-%1-%2.txt" move /Y "%TEMP%\ValidDynamicLinks-%1-%2.txt" ..\static\custom\StaticDownloadLinks-%1-%2.txt >nul
  1365. ) else (
  1366.   if exist "%TEMP%\ValidDynamicLinks-%1-%2.txt" del "%TEMP%\ValidDynamicLinks-%1-%2.txt"
  1367. )
  1368. goto :eof
  1369.  
  1370. :RemindDate
  1371. rem *** Remind build date ***
  1372. if "%SKIP_DL%"=="1" goto EoF
  1373. echo Reminding build date...
  1374. echo %DATE:~-10%>..\client\builddate.txt
  1375. goto EoF
  1376.  
  1377. :NoExtensions
  1378. echo.
  1379. echo ERROR: No command extensions / delayed variable expansion available.
  1380. echo.
  1381. exit /b 1
  1382.  
  1383. :InvalidParams
  1384. echo.
  1385. echo ERROR: Invalid parameter: %*
  1386. echo Usage1: %~n0 {wxp ^| w2k3 ^| w2k3-x64 ^| o2k3 ^| o2k7 ^| o2k10} {enu ^| fra ^| esn ^| jpn ^| kor ^| rus ^| ptg ^| ptb ^| deu ^| nld ^| ita ^| chs ^| cht ^| plk ^| hun ^| csy ^| sve ^| trk ^| ell ^| ara ^| heb ^| dan ^| nor ^| fin} [/excludesp ^| /excludestatics] [/includedotnet] [/includemsse] [/includewddefs] [/nocleanup] [/verify] [/skiptz] [/skipdownload] [/skipdynamic] [/proxy http://[username:password@]^<server^>:^<port^>] [/wsus http://^<server^>] [/wsusonly] [/wsusbyproxy]
  1387. echo Usage2: %~n0 {w60 ^| w60-x64 ^| w61 ^| w61-x64 ^| w62 ^| w62-x64 ^| ofc ^| o2k13} {glb} [/excludesp ^| /excludestatics] [/includedotnet] [/includemsse] [/includewddefs] [/nocleanup] [/verify] [/skiptz] [/skipdownload] [/skipdynamic] [/proxy http://[username:password@]^<server^>:^<port^>] [/wsus http://^<server^>] [/wsusonly] [/wsusbyproxy]
  1388. echo %DATE% %TIME% - Error: Invalid parameter: %* >>%DOWNLOAD_LOGFILE%
  1389. echo.
  1390. goto Error
  1391.  
  1392. :NoTemp
  1393. echo.
  1394. echo ERROR: Environment variable TEMP not set.
  1395. echo %DATE% %TIME% - Error: Environment variable TEMP not set >>%DOWNLOAD_LOGFILE%
  1396. echo.
  1397. goto Error
  1398.  
  1399. :NoTempDir
  1400. echo.
  1401. echo ERROR: Directory "%TEMP%" not found.
  1402. echo %DATE% %TIME% - Error: Directory "%TEMP%" not found >>%DOWNLOAD_LOGFILE%
  1403. echo.
  1404. goto Error
  1405.  
  1406. :NoCScript
  1407. echo.
  1408. echo ERROR: VBScript interpreter %CSCRIPT_PATH% not found.
  1409. echo %DATE% %TIME% - Error: VBScript interpreter %CSCRIPT_PATH% not found >>%DOWNLOAD_LOGFILE%
  1410. echo.
  1411. goto Error
  1412.  
  1413. :NoAria
  1414. echo.
  1415. echo ERROR: Download utility %ARIA_PATH% --console-log-level=error --log-level=warn -x10 -j10 -s10 -k1M not found.
  1416. echo %DATE% %TIME% - Error: Download utility %ARIA_PATH% --console-log-level=error --log-level=warn -x10 -j10 -s10 -k1M not found >>%DOWNLOAD_LOGFILE%
  1417. echo.
  1418. goto Error
  1419.  
  1420. :NoUnZip
  1421. echo.
  1422. echo ERROR: Utility ..\bin\unzip.exe not found.
  1423. echo %DATE% %TIME% - Error: Utility ..\bin\unzip.exe not found >>%DOWNLOAD_LOGFILE%
  1424. echo.
  1425. goto Error
  1426.  
  1427. :NoHashDeep
  1428. echo.
  1429. echo ERROR: Hash computing/auditing utility ..\client\bin\%HASHDEEP_EXE% not found.
  1430. echo %DATE% %TIME% - Error: Hash computing/auditing utility ..\client\bin\%HASHDEEP_EXE% not found >>%DOWNLOAD_LOGFILE%
  1431. echo.
  1432. goto Error
  1433.  
  1434. :NoSigCheck
  1435. echo.
  1436. echo ERROR: Sysinternals' digital file signature verification tool ..\bin\sigcheck.exe not found.
  1437. echo %DATE% %TIME% - Error: Sysinternals' digital file signature verification tool ..\bin\sigcheck.exe not found >>%DOWNLOAD_LOGFILE%
  1438. echo.
  1439. goto Error
  1440.  
  1441. :DownloadError
  1442. echo.
  1443. echo ERROR: Download failure for %1 %2.
  1444. echo %DATE% %TIME% - Error: Download failure for %1 %2 >>%DOWNLOAD_LOGFILE%
  1445. echo.
  1446. goto Error
  1447.  
  1448. :IntegrityError
  1449. echo.
  1450. echo ERROR: File integrity verification failure.
  1451. echo %DATE% %TIME% - Error: File integrity verification failure >>%DOWNLOAD_LOGFILE%
  1452. echo.
  1453. goto Error
  1454.  
  1455. :SignatureError
  1456. echo.
  1457. echo ERROR: File signature verification failure.
  1458. echo %DATE% %TIME% - Error: File signature verification failure >>%DOWNLOAD_LOGFILE%
  1459. echo.
  1460. goto Error
  1461.  
  1462. :Error
  1463. if "%EXIT_ERR%"=="1" (
  1464.   endlocal
  1465.   pause
  1466.   verify other 2>nul
  1467.   exit
  1468. ) else (
  1469.   title %ComSpec%
  1470.   endlocal
  1471.   verify other 2>nul
  1472.   goto :eof
  1473. )
  1474.  
  1475. :EoF
  1476. rem *** Execute custom finalization hook ***
  1477. if exist .\custom\FinalizationHook.cmd (
  1478.   echo Executing custom finalization hook...
  1479.   pushd .\custom
  1480.   call FinalizationHook.cmd
  1481.   popd
  1482.   echo %DATE% %TIME% - Info: Executed custom finalization hook ^(Errorlevel: %errorlevel%^) >>%DOWNLOAD_LOGFILE%
  1483. )
  1484. echo Done.
  1485. echo %DATE% %TIME% - Info: Ending WSUS Offline Update download for %1 %2 >>%DOWNLOAD_LOGFILE%
  1486. title %ComSpec%
  1487. endlocal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement