Ticket #67: DoUpdate.cmd.txt

File DoUpdate.cmd.txt, 34.2 KB (added by esau_matt, 6 years ago)
Line 
1@echo off
2rem *** Author: T. Wittrock, RZ Uni Kiel ***
3
4verify other 2>nul
5setlocal enableextensions
6if errorlevel 1 goto NoExtensions
7
8if "%DIRCMD%" NEQ "" set DIRCMD=
9
10%~d0
11cd "%~p0"
12
13set UPDATE_MEDIUM=\\server\freigabe$\client
14set CTUPDATE_VERSION=5.1
15set UPDATE_LOGFILE=%SystemRoot%\ctupdate.log
16title %~n0 %*
17echo Starting offline update (v. %CTUPDATE_VERSION%)...
18if exist %UPDATE_LOGFILE% echo. >>%UPDATE_LOGFILE%
19echo %DATE% %TIME% - Info: Starting update (v. %CTUPDATE_VERSION%) on %COMPUTERNAME% (user: %USERNAME%) >>%UPDATE_LOGFILE%
20
21:EvalParams
22if "%1"=="" goto NoMoreParams
23if /i "%1"=="/nobackup" set BACKUP_MODE=/nobackup
24if /i "%1"=="/instie7" set INSTALL_IE7=/instie7
25if /i "%1"=="/instdotnet" set INSTALL_DOTNET=/instdotnet
26if /i "%1"=="/ignoreoffice" set IGNORE_OFFICE=/ignoreoffice
27if /i "%1"=="/instofccnvs" set INSTALL_CONVERTERS=/instofccnvs
28if /i "%1"=="/autoreboot" set BOOT_MODE=/autoreboot
29if /i "%1"=="/showlog" set SHOW_LOG=/showlog
30if /i "%1"=="/all" set LIST_MODE_IDS=/all
31if /i "%1"=="/excludestatics" set LIST_MODE_UPDATES=/excludestatics
32shift /1
33goto EvalParams
34
35:NoMoreParams
36if "%TEMP%"=="" goto NoTemp
37pushd "%TEMP%"
38if errorlevel 1 goto NoTempDir
39popd
40
41set CSCRIPT_PATH=%SystemRoot%\system32\cscript.exe
42if not exist %CSCRIPT_PATH% goto NoCScript
43
44if exist %SystemRoot%\system32\reg.exe (
45  set REG_PATH=%SystemRoot%\system32\reg.exe
46) else (
47  set REG_PATH=..\bin\reg.exe
48)
49if "%BOOT_MODE%"=="/autoreboot" (if not exist %REG_PATH% goto NoReg)
50if "%SHOW_LOG%"=="/showlog" (if not exist %REG_PATH% goto NoReg)
51
52rem *** Check number of automatic recalls ***
53if "%USERNAME%"=="WSUSUpdateAdmin" (
54  if exist "%TEMP%\wsusadmin-recall.3" goto EndlessLoop
55  if exist "%TEMP%\wsusadmin-recall.2" ren "%TEMP%\wsusadmin-recall.2" wsusadmin-recall.3
56  if exist "%TEMP%\wsusadmin-recall.1" (
57    ren "%TEMP%\wsusadmin-recall.1" wsusadmin-recall.2
58  ) else (
59    echo recall>"%TEMP%\wsusadmin-recall.1"
60  )
61)
62
63rem *** Determine system's properties ***
64echo Determining system's properties...
65%CSCRIPT_PATH% //Nologo //E:vbs DetermineSystemProperties.vbs %IGNORE_OFFICE%
66if errorlevel 1 goto NoSysEnvVars
67
68rem *** Set environment variables for system's properties ***
69if not exist "%TEMP%\SetSystemEnvVars.cmd" goto NoSysEnvVars
70call "%TEMP%\SetSystemEnvVars.cmd"
71del "%TEMP%\SetSystemEnvVars.cmd"
72if "%SystemDirectory%"=="" set SystemDirectory=%SystemRoot%\system32
73if "%OS_ARCHITECTURE%"=="" set OS_ARCHITECTURE=%PROCESSOR_ARCHITECTURE%
74if "%OS_LANGUAGE%"=="" goto UnsupLang
75
76rem *** Set target environment variables ***
77call SetTargetEnvVars.cmd %INSTALL_IE7%
78if errorlevel 1 goto Cleanup
79if "%OS_NAME%"=="" goto NoOSName
80
81rem *** Echo OS properties ***
82echo Found Operating System caption: %OS_CAPTION%
83echo Found Microsoft Windows version: %OS_VERSION_MAJOR%.%OS_VERSION_MINOR%.%OS_VERSION_BUILD% (%OS_NAME% %OS_ARCHITECTURE% %OS_LANGUAGE% sp%OS_SP_VERSION_MAJOR%)
84rem echo Found Windows Update Agent version: %WUA_VERSION_MAJOR%.%WUA_VERSION_MINOR%.%WUA_VERSION_BUILD%.%WUA_VERSION_REVISION%
85rem echo Found Windows Installer version: %MSI_VERSION_MAJOR%.%MSI_VERSION_MINOR%.%MSI_VERSION_BUILD%.%MSI_VERSION_REVISION%
86rem echo Found Windows Script Host version: %WSH_VERSION_MAJOR%.%WSH_VERSION_MINOR%.%WSH_VERSION_BUILD%.%WSH_VERSION_REVISION%
87rem echo Found Internet Explorer version: %IE_VERSION_MAJOR%.%IE_VERSION_MINOR%.%IE_VERSION_BUILD%.%IE_VERSION_REVISION%
88rem echo Found Microsoft Data Access Components version: %MDAC_VERSION_MAJOR%.%MDAC_VERSION_MINOR%.%MDAC_VERSION_BUILD%.%MDAC_VERSION_REVISION%
89rem echo Found Microsoft DirectX version: %DIRECTX_VERSION_MAJOR%.%DIRECTX_VERSION_MINOR%.%DIRECTX_VERSION_BUILD%.%DIRECTX_VERSION_REVISION% (%DX_NAME%)
90rem echo Found Microsoft .NET Framework 3.5 version: %DOTNET_VERSION_MAJOR%.%DOTNET_VERSION_MINOR%.%DOTNET_VERSION_BUILD%.%DOTNET_VERSION_REVISION%
91rem echo Found Windows Media Player version: %WMP_VERSION_MAJOR%.%WMP_VERSION_MINOR%.%WMP_VERSION_BUILD%.%WMP_VERSION_REVISION%
92if "%IGNORE_OFFICE%"=="/ignoreoffice" (
93  echo Info: Skipped detection of Microsoft Office as requested.
94)
95if not "%OFFICE_NAME%"=="" (
96  echo Found Microsoft Office %OFFICE_VERSION_APP% version: %OFFICE_VERSION_MAJOR%.%OFFICE_VERSION_MINOR%.%OFFICE_VERSION_BUILD% ^(%OFFICE_NAME% %OFFICE_LANGUAGE% sp%OFFICE_SP_VERSION%^)
97)
98echo %DATE% %TIME% - Info: Found Operating System caption '%OS_CAPTION%' >>%UPDATE_LOGFILE%
99echo %DATE% %TIME% - Info: Found Microsoft Windows version %OS_VERSION_MAJOR%.%OS_VERSION_MINOR%.%OS_VERSION_BUILD% (%OS_NAME% %OS_ARCHITECTURE% %OS_LANGUAGE% sp%OS_SP_VERSION_MAJOR%) >>%UPDATE_LOGFILE%
100echo %DATE% %TIME% - Info: Found Windows Update Agent version %WUA_VERSION_MAJOR%.%WUA_VERSION_MINOR%.%WUA_VERSION_BUILD%.%WUA_VERSION_REVISION% >>%UPDATE_LOGFILE%
101echo %DATE% %TIME% - Info: Found Windows Installer version %MSI_VERSION_MAJOR%.%MSI_VERSION_MINOR%.%MSI_VERSION_BUILD%.%MSI_VERSION_REVISION% >>%UPDATE_LOGFILE%
102echo %DATE% %TIME% - Info: Found Windows Script Host version %WSH_VERSION_MAJOR%.%WSH_VERSION_MINOR%.%WSH_VERSION_BUILD%.%WSH_VERSION_REVISION% >>%UPDATE_LOGFILE%
103echo %DATE% %TIME% - Info: Found Internet Explorer version %IE_VERSION_MAJOR%.%IE_VERSION_MINOR%.%IE_VERSION_BUILD%.%IE_VERSION_REVISION% >>%UPDATE_LOGFILE%
104echo %DATE% %TIME% - Info: Found Microsoft Data Access Components version %MDAC_VERSION_MAJOR%.%MDAC_VERSION_MINOR%.%MDAC_VERSION_BUILD%.%MDAC_VERSION_REVISION% >>%UPDATE_LOGFILE%
105echo %DATE% %TIME% - Info: Found Microsoft DirectX version %DIRECTX_VERSION_MAJOR%.%DIRECTX_VERSION_MINOR%.%DIRECTX_VERSION_BUILD%.%DIRECTX_VERSION_REVISION% (%DX_NAME%) >>%UPDATE_LOGFILE%
106echo %DATE% %TIME% - Info: Found Microsoft .NET Framework 3.5 version %DOTNET_VERSION_MAJOR%.%DOTNET_VERSION_MINOR%.%DOTNET_VERSION_BUILD%.%DOTNET_VERSION_REVISION% >>%UPDATE_LOGFILE%
107echo %DATE% %TIME% - Info: Found Windows Media Player version %WMP_VERSION_MAJOR%.%WMP_VERSION_MINOR%.%WMP_VERSION_BUILD%.%WMP_VERSION_REVISION% >>%UPDATE_LOGFILE%
108if "%IGNORE_OFFICE%"=="/ignoreoffice" (
109  echo %DATE% %TIME% - Info: Skipped detection of Microsoft Office as requested >>%UPDATE_LOGFILE%
110)
111if not "%OFFICE_NAME%"=="" (
112  echo %DATE% %TIME% - Info: Found Microsoft Office %OFFICE_VERSION_APP% version %OFFICE_VERSION_MAJOR%.%OFFICE_VERSION_MINOR%.%OFFICE_VERSION_BUILD% ^(%OFFICE_NAME% %OFFICE_LANGUAGE% sp%OFFICE_SP_VERSION%^) >>%UPDATE_LOGFILE%
113)
114
115rem *** Check Operating System architecture ***
116for %%i in (x86 x64) do (if /i "%OS_ARCHITECTURE%"=="%%i" goto ValidArch)
117goto UnsupArch
118:ValidArch
119
120rem *** Check Operating System Service Pack level ***
121if "%OS_NAME%"=="wxp" (
122  if 0 EQU %OS_SP_VERSION_MAJOR% goto UnsupSP
123)
124
125rem *** Check availability of /autoreboot switch ***
126if "%BOOT_MODE%"=="/autoreboot" (
127  if "%DOMAIN_ROLE%"=="4" goto NoAutoReboot
128  if "%DOMAIN_ROLE%"=="5" goto NoAutoReboot
129)
130
131rem *** Check user's privileges ***
132echo Checking user's privileges...
133if not exist ..\bin\IfAdmin.exe goto NoIfAdmin
134..\bin\IfAdmin.exe
135if not errorlevel 1 goto NoAdmin
136
137rem *** Check medium content ***
138echo Checking medium content...
139if /i "%OS_ARCHITECTURE%"=="x64" (
140  if exist %UPDATE_MEDIUM%\%OS_NAME%-%OS_ARCHITECTURE%\%OS_LANGUAGE%\. (
141    echo Info: Medium supports Microsoft Windows ^(%OS_NAME%-%OS_ARCHITECTURE% %OS_LANGUAGE%^).
142    echo %DATE% %TIME% - Info: Medium supports Microsoft Windows ^(%OS_NAME%-%OS_ARCHITECTURE% %OS_LANGUAGE%^) >>%UPDATE_LOGFILE%
143    goto CheckOfficeMedium
144  )
145  if exist %UPDATE_MEDIUM%\%OS_NAME%-%OS_ARCHITECTURE%\glb\. (
146    echo Info: Medium supports Microsoft Windows ^(%OS_NAME%-%OS_ARCHITECTURE% glb^).
147    echo %DATE% %TIME% - Info: Medium supports Microsoft Windows ^(%OS_NAME%-%OS_ARCHITECTURE% glb^) >>%UPDATE_LOGFILE%
148    goto CheckOfficeMedium
149  )
150) else (
151  if exist %UPDATE_MEDIUM%\%OS_NAME%\%OS_LANGUAGE%\. (
152    echo Info: Medium supports Microsoft Windows ^(%OS_NAME% %OS_LANGUAGE%^).
153    echo %DATE% %TIME% - Info: Medium supports Microsoft Windows ^(%OS_NAME% %OS_LANGUAGE%^) >>%UPDATE_LOGFILE%
154    goto CheckOfficeMedium
155  )
156  if exist %UPDATE_MEDIUM%\%OS_NAME%\glb\. (
157    echo Info: Medium supports Microsoft Windows ^(%OS_NAME% glb^).
158    echo %DATE% %TIME% - Info: Medium supports Microsoft Windows ^(%OS_NAME% glb^) >>%UPDATE_LOGFILE%
159    goto CheckOfficeMedium
160  )
161)
162echo Info: Medium does not support Microsoft Windows (%OS_NAME% %OS_LANGUAGE%).
163echo %DATE% %TIME% - Info: Medium does not support Microsoft Windows (%OS_NAME% %OS_LANGUAGE%) >>%UPDATE_LOGFILE%
164if "%IGNORE_OFFICE%"=="/ignoreoffice" goto InvalidMedium
165if "%OFFICE_NAME%"=="" goto InvalidMedium
166if not exist %UPDATE_MEDIUM%\%OFFICE_NAME%\%OFFICE_LANGUAGE%\. (
167  if not exist %UPDATE_MEDIUM%\%OFFICE_NAME%\glb\. (
168    if not exist %UPDATE_MEDIUM%\%OFFICE_NAME%-%OS_ARCHITECTURE%\glb\. (
169      echo Info: Medium does not support Microsoft Office ^(%OFFICE_NAME% %OFFICE_LANGUAGE%^).
170      echo %DATE% %TIME% - Info: Medium does not support Microsoft Office ^(%OFFICE_NAME% %OFFICE_LANGUAGE%^) >>%UPDATE_LOGFILE%
171      goto InvalidMedium
172    )
173  )
174)
175:CheckOfficeMedium
176if "%IGNORE_OFFICE%"=="/ignoreoffice" goto ProperMedium
177if "%OFFICE_NAME%"=="" goto ProperMedium
178if exist %UPDATE_MEDIUM%\%OFFICE_NAME%\%OFFICE_LANGUAGE%\. (
179  echo Info: Medium supports Microsoft Office ^(%OFFICE_NAME% %OFFICE_LANGUAGE%^).
180  echo %DATE% %TIME% - Info: Medium supports Microsoft Office ^(%OFFICE_NAME% %OFFICE_LANGUAGE%^) >>%UPDATE_LOGFILE%
181  goto ProperMedium
182)
183if exist %UPDATE_MEDIUM%\%OFFICE_NAME%\glb\. (
184  echo Info: Medium supports Microsoft Office ^(%OFFICE_NAME% glb^).
185  echo %DATE% %TIME% - Info: Medium supports Microsoft Office ^(%OFFICE_NAME% glb^) >>%UPDATE_LOGFILE%
186  goto ProperMedium
187)
188if exist %UPDATE_MEDIUM%\%OFFICE_NAME%-%OS_ARCHITECTURE%\glb\. (
189  echo Info: Medium supports Microsoft Office ^(%OFFICE_NAME%-%OS_ARCHITECTURE% glb^).
190  echo %DATE% %TIME% - Info: Medium supports Microsoft Office ^(%OFFICE_NAME%-%OS_ARCHITECTURE% glb^) >>%UPDATE_LOGFILE%
191  goto ProperMedium
192)
193echo Info: Medium does not support Microsoft Office (%OFFICE_NAME% %OFFICE_LANGUAGE%).
194echo %DATE% %TIME% - Info: Medium does not support Microsoft Office (%OFFICE_NAME% %OFFICE_LANGUAGE%) >>%UPDATE_LOGFILE%
195:ProperMedium
196
197rem *** Install Windows Service Pack ***
198echo Checking Windows Service Pack version...
199if %OS_SP_VERSION_MAJOR% GEQ %OS_SP_VERSION_TARGET_MAJOR% goto SkipSPInst
200if "%OS_SP_TARGET_ID%"=="" goto NoSPTargetId
201echo %OS_SP_TARGET_ID%>"%TEMP%\MissingUpdateIds.txt"
202call ListUpdatesToInstall.cmd /excludestatics
203if errorlevel 1 goto ListError
204if not exist "%TEMP%\UpdatesToInstall.txt" (
205  if "%IGNORE_OFFICE%"=="/ignoreoffice" goto NoUpdates
206  if "%OFFICE_NAME%"=="" goto NoUpdates
207  if not exist %UPDATE_MEDIUM%\%OFFICE_NAME%\%OFFICE_LANGUAGE%\. (
208    if not exist %UPDATE_MEDIUM%\%OFFICE_NAME%\glb\. goto NoUpdates
209  )
210  echo Warning: Windows Service Pack installation file not found.
211  echo %DATE% %TIME% - Warning: Windows Service Pack installation file not found >>%UPDATE_LOGFILE%
212  goto SkipSPInst
213)
214echo Installing most recent Windows Service Pack...
215goto SP%OS_NAME%
216
217:SPw2k
218:SPwxp
219:SPw2k3
220if "%BACKUP_MODE%"=="/nobackup" (
221  call InstallListedUpdates.cmd /u /z /n
222) else (
223  call InstallListedUpdates.cmd /u /z
224)
225if errorlevel 1 goto InstError
226set RECALL_REQUIRED=1
227goto Installed
228
229:SPw60
230echo %DATE% %TIME% - Info: Installing most recent Service Pack for Windows Vista >>%UPDATE_LOGFILE%
231call InstallListedUpdates.cmd /unattend /forcerestart
232if errorlevel 1 goto InstError
233set RECALL_REQUIRED=1
234goto Installed
235
236:SkipSPInst
237
238rem *** Install DirectX End-User Runtime ***
239if "%OS_NAME%"=="w60" goto SkipDirectXInst
240echo Checking DirectX version...
241if %DIRECTX_VERSION_MAJOR% LSS %DIRECTX_VERSION_TARGET_MAJOR% goto InstallDirectX
242if %DIRECTX_VERSION_MAJOR% GTR %DIRECTX_VERSION_TARGET_MAJOR% goto SkipDirectXInst
243if %DIRECTX_VERSION_MINOR% LSS %DIRECTX_VERSION_TARGET_MINOR% goto InstallDirectX
244if %DIRECTX_VERSION_MINOR% GTR %DIRECTX_VERSION_TARGET_MINOR% goto SkipDirectXInst
245if %DIRECTX_VERSION_BUILD% LSS %DIRECTX_VERSION_TARGET_BUILD% goto InstallDirectX
246if %DIRECTX_VERSION_BUILD% GTR %DIRECTX_VERSION_TARGET_BUILD% goto SkipDirectXInst
247if %DIRECTX_VERSION_REVISION% GEQ %DIRECTX_VERSION_TARGET_REVISION% goto SkipDirectXInst
248:InstallDirectX
249set DIRECTX_FILENAME=%UPDATE_MEDIUM%\win\glb\directx_*_redist.exe
250dir /B %DIRECTX_FILENAME% >nul 2>&1
251if errorlevel 1 (
252  echo Warning: File %DIRECTX_FILENAME% not found.
253  echo %DATE% %TIME% - Warning: File %DIRECTX_FILENAME% not found >>%UPDATE_LOGFILE%
254) else (
255  echo Installing most recent DirectX End-User Runtime...
256  for /F %%i in ('dir /B %DIRECTX_FILENAME%') do (
257    echo Installing %UPDATE_MEDIUM%\win\glb\%%i...
258    %UPDATE_MEDIUM%\win\glb\%%i /Q /T:"%TEMP%\directx" /C
259    "%TEMP%\directx\dxsetup.exe" /silent
260    call SafeRmDir.cmd "%TEMP%\directx"
261    echo %DATE% %TIME% - Info: Installed %UPDATE_MEDIUM%\win\glb\%%i >>%UPDATE_LOGFILE%
262    set RECALL_REQUIRED=1
263    goto Installed
264  )
265)
266:SkipDirectXInst
267
268rem *** Install Windows Update Agent ***
269echo Checking Windows Update Agent version...
270if %WUA_VERSION_MAJOR% LSS %WUA_VERSION_TARGET_MAJOR% goto InstallWUA
271if %WUA_VERSION_MAJOR% GTR %WUA_VERSION_TARGET_MAJOR% goto SkipWUAInst
272if %WUA_VERSION_MINOR% LSS %WUA_VERSION_TARGET_MINOR% goto InstallWUA
273if %WUA_VERSION_MINOR% GTR %WUA_VERSION_TARGET_MINOR% goto SkipWUAInst
274if %WUA_VERSION_BUILD% LSS %WUA_VERSION_TARGET_BUILD% goto InstallWUA
275if %WUA_VERSION_BUILD% GTR %WUA_VERSION_TARGET_BUILD% goto SkipWUAInst
276if %WUA_VERSION_REVISION% GEQ %WUA_VERSION_TARGET_REVISION% goto SkipWUAInst
277:InstallWUA
278set WUA_FILENAME=%UPDATE_MEDIUM%\wsus\WindowsUpdateAgent*-%OS_ARCHITECTURE%.exe
279dir /B %WUA_FILENAME% >nul 2>&1
280if errorlevel 1 goto NoWUAInst
281echo Installing most recent Windows Update Agent...
282for /F %%i in ('dir /B %WUA_FILENAME%') do (
283  call InstallOSUpdate.cmd %UPDATE_MEDIUM%\wsus\%%i /wuforce /quiet /norestart
284  if errorlevel 1 goto InstError
285  set RECALL_REQUIRED=1
286)
287:SkipWUAInst
288
289rem *** Install Windows Installer ***
290echo Checking Windows Installer version...
291if %MSI_VERSION_MAJOR% LSS %MSI_VERSION_TARGET_MAJOR% goto InstallMSI
292if %MSI_VERSION_MAJOR% GTR %MSI_VERSION_TARGET_MAJOR% goto SkipMSIInst
293if %MSI_VERSION_MINOR% LSS %MSI_VERSION_TARGET_MINOR% goto InstallMSI
294if %MSI_VERSION_MINOR% GTR %MSI_VERSION_TARGET_MINOR% goto SkipMSIInst
295if %MSI_VERSION_BUILD% LSS %MSI_VERSION_TARGET_BUILD% goto InstallMSI
296if %MSI_VERSION_BUILD% GTR %MSI_VERSION_TARGET_BUILD% goto SkipMSIInst
297if %MSI_VERSION_REVISION% GEQ %MSI_VERSION_TARGET_REVISION% goto SkipMSIInst
298:InstallMSI
299if /i "%OS_ARCHITECTURE%"=="x64" (
300  set MSI_FILENAME=%UPDATE_MEDIUM%\%OS_NAME%-%OS_ARCHITECTURE%\glb\*%MSI_TARGET_ID%*-%OS_ARCHITECTURE%.*
301) else (
302  set MSI_FILENAME=%UPDATE_MEDIUM%\%OS_NAME%\glb\*%MSI_TARGET_ID%*-%OS_ARCHITECTURE%.*
303)
304dir /B %MSI_FILENAME% >nul 2>&1
305if errorlevel 1 (
306  echo Warning: File %MSI_FILENAME% not found.
307  echo %DATE% %TIME% - Warning: File %MSI_FILENAME% not found >>%UPDATE_LOGFILE%
308) else (
309  echo Installing most recent Windows Installer...
310  for /F %%i in ('dir /B %MSI_FILENAME%') do (
311    if /i "%OS_ARCHITECTURE%"=="x64" (
312      call InstallOSUpdate.cmd %UPDATE_MEDIUM%\%OS_NAME%-%OS_ARCHITECTURE%\glb\%%i /quiet %BACKUP_MODE% /norestart
313    ) else (
314      call InstallOSUpdate.cmd %UPDATE_MEDIUM%\%OS_NAME%\glb\%%i /quiet %BACKUP_MODE% /norestart
315    )
316    if errorlevel 0 set RECALL_REQUIRED=1
317  )
318)
319:SkipMSIInst
320
321rem *** Install Windows Script Host ***
322if /i "%OS_ARCHITECTURE%"=="x64" goto SkipWSHInst
323echo Checking Windows Script Host version...
324if %WSH_VERSION_MAJOR% LSS %WSH_VERSION_TARGET_MAJOR% goto InstallWSH
325if %WSH_VERSION_MAJOR% GTR %WSH_VERSION_TARGET_MAJOR% goto SkipWSHInst
326if %WSH_VERSION_MINOR% LSS %WSH_VERSION_TARGET_MINOR% goto InstallWSH
327if %WSH_VERSION_MINOR% GTR %WSH_VERSION_TARGET_MINOR% goto SkipWSHInst
328if %WSH_VERSION_BUILD% LSS %WSH_VERSION_TARGET_BUILD% goto InstallWSH
329if %WSH_VERSION_BUILD% GTR %WSH_VERSION_TARGET_BUILD% goto SkipWSHInst
330if %WSH_VERSION_REVISION% GEQ %WSH_VERSION_TARGET_REVISION% goto SkipWSHInst
331:InstallWSH
332set WSH_FILENAME=%UPDATE_MEDIUM%\win\%OS_LANGUAGE%\Windows*-Script56-KB917344-%OS_ARCHITECTURE%-%OS_LANGUAGE%.exe
333dir /B %WSH_FILENAME% >nul 2>&1
334if errorlevel 1 (
335  echo Warning: File %WSH_FILENAME% not found.
336  echo %DATE% %TIME% - Warning: File %WSH_FILENAME% not found >>%UPDATE_LOGFILE%
337) else (
338  echo Installing most recent Windows Script Host...
339  for /F %%i in ('dir /B %WSH_FILENAME%') do (
340    call InstallOSUpdate.cmd %UPDATE_MEDIUM%\win\%OS_LANGUAGE%\%%i /q:a /r:n
341    if errorlevel 0 set RECALL_REQUIRED=1
342  )
343)
344:SkipWSHInst
345
346rem *** Install Internet Explorer ***
347echo Checking Internet Explorer version...
348if %IE_VERSION_MAJOR% LSS %IE_VERSION_TARGET_MAJOR% goto InstallIE
349if %IE_VERSION_MAJOR% GTR %IE_VERSION_TARGET_MAJOR% goto SkipIEInst
350if %IE_VERSION_MINOR% LSS %IE_VERSION_TARGET_MINOR% goto InstallIE
351if %IE_VERSION_MINOR% GTR %IE_VERSION_TARGET_MINOR% goto SkipIEInst
352if %IE_VERSION_BUILD% LSS %IE_VERSION_TARGET_BUILD% goto InstallIE
353if %IE_VERSION_BUILD% GTR %IE_VERSION_TARGET_BUILD% goto SkipIEInst
354if %IE_VERSION_REVISION% GEQ %IE_VERSION_TARGET_REVISION% goto SkipIEInst
355:InstallIE
356goto IE%OS_NAME%
357
358:IEw2k
359set IE_FILENAME=%UPDATE_MEDIUM%\win\%OS_LANGUAGE%\ie6setup\ie6setup.exe
360if not exist %IE_FILENAME% (
361  echo Warning: Unable to install Internet Explorer 6. File %IE_FILENAME% not found.
362  echo %DATE% %TIME% - Warning: Unable to install Internet Explorer 6. File %IE_FILENAME% not found >>%UPDATE_LOGFILE%
363  goto SkipIEInst
364)
365echo Installing Internet Explorer 6...
366call InstallOSUpdate.cmd %IE_FILENAME% /q:a /r:n
367if errorlevel 0 set RECALL_REQUIRED=1
368goto SkipIEInst
369
370:IEwxp
371set IE_FILENAME=%UPDATE_MEDIUM%\%OS_NAME%\%OS_LANGUAGE%\ie7-windowsxp-%OS_ARCHITECTURE%-%OS_LANGUAGE%*.exe
372goto IEwxp2k3
373
374:IEw2k3
375if /i "%OS_ARCHITECTURE%"=="x64" (
376  set IE_FILENAME=%UPDATE_MEDIUM%\%OS_NAME%-%OS_ARCHITECTURE%\%OS_LANGUAGE%\ie7-windowsserver2003-%OS_ARCHITECTURE%-%OS_LANGUAGE%*.exe
377) else (
378  set IE_FILENAME=%UPDATE_MEDIUM%\%OS_NAME%\%OS_LANGUAGE%\ie7-windowsserver2003-%OS_ARCHITECTURE%-%OS_LANGUAGE%*.exe
379)
380goto IEwxp2k3
381
382:IEwxp2k3
383dir /B %IE_FILENAME% >nul 2>&1
384if errorlevel 1 (
385  echo Warning: File %IE_FILENAME% not found.
386  echo %DATE% %TIME% - Warning: File %IE_FILENAME% not found >>%UPDATE_LOGFILE%
387) else (
388  echo Installing Internet Explorer 7...
389  for /F %%i in ('dir /B %IE_FILENAME%') do (
390    if /i "%OS_ARCHITECTURE%"=="x64" (
391      call InstallOSUpdate.cmd %UPDATE_MEDIUM%\%OS_NAME%-%OS_ARCHITECTURE%\%OS_LANGUAGE%\%%i /quiet /update-no /no-default %BACKUP_MODE% /norestart
392    ) else (
393      call InstallOSUpdate.cmd %UPDATE_MEDIUM%\%OS_NAME%\%OS_LANGUAGE%\%%i /quiet /update-no /no-default %BACKUP_MODE% /norestart
394    )
395    if errorlevel 0 set RECALL_REQUIRED=1
396  )
397)
398
399:IEw60
400:SkipIEInst
401if "%RECALL_REQUIRED%"=="1" goto Installed
402
403rem *** Install .NET Framework 3.5 SP1 ***
404if "%OS_NAME%"=="w2k" goto SkipDotNetInst
405if "%INSTALL_DOTNET%" NEQ "/instdotnet" goto SkipDotNetInst
406echo Checking .NET Framework 3.5 installation state...
407if %DOTNET_VERSION_MAJOR% LSS %DOTNET_VERSION_TARGET_MAJOR% goto InstallDotNet
408if %DOTNET_VERSION_MAJOR% GTR %DOTNET_VERSION_TARGET_MAJOR% goto SkipDotNetInst
409if %DOTNET_VERSION_MINOR% LSS %DOTNET_VERSION_TARGET_MINOR% goto InstallDotNet
410if %DOTNET_VERSION_MINOR% GTR %DOTNET_VERSION_TARGET_MINOR% goto SkipDotNetInst
411if %DOTNET_VERSION_BUILD% LSS %DOTNET_VERSION_TARGET_BUILD% goto InstallDotNet
412if %DOTNET_VERSION_BUILD% GTR %DOTNET_VERSION_TARGET_BUILD% goto SkipDotNetInst
413if %DOTNET_VERSION_REVISION% GEQ %DOTNET_VERSION_TARGET_REVISION% goto SkipDotNetInst
414:InstallDotNet
415set DOTNET_FILENAME=%UPDATE_MEDIUM%\dotnet\dotnetfx35.exe
416if exist %DOTNET_FILENAME% (
417  echo Installing .NET Framework 3.5 SP1...
418  call InstallOSUpdate.cmd %DOTNET_FILENAME% /qb /norestart /lang:%OS_LANGUAGE%
419  copy /Y %UPDATE_MEDIUM%\static\StaticUpdateIds-dotnet.txt "%TEMP%\MissingUpdateIds.txt" >nul
420  call ListUpdatesToInstall.cmd /excludestatics
421  if errorlevel 1 goto ListError
422  if exist "%TEMP%\UpdatesToInstall.txt" (
423    echo Installing .NET Framework 3.5 SP1 Family Update...
424    call InstallListedUpdates.cmd /selectoptions %BACKUP_MODE% /errorsaswarnings
425  )
426) else (
427  echo Warning: File %DOTNET_FILENAME% not found.
428  echo %DATE% %TIME% - Warning: File %DOTNET_FILENAME% not found >>%UPDATE_LOGFILE%
429  goto SkipDotNetInst
430)
431set REBOOT_REQUIRED=1
432:SkipDotNetInst
433
434if "%IGNORE_OFFICE%"=="/ignoreoffice" goto CheckAUService
435if "%OFFICE_NAME%"=="" goto CheckAUService
436if not exist %UPDATE_MEDIUM%\%OFFICE_NAME%\%OFFICE_LANGUAGE%\. (
437  if not exist %UPDATE_MEDIUM%\%OFFICE_NAME%\glb\. goto CheckAUService
438)
439rem *** Check Office Service Pack version ***
440echo Checking Office Service Pack version...
441if %OFFICE_SP_VERSION% GEQ %OFFICE_SP_VERSION_TARGET% goto SkipSPOfc
442goto SP%OFFICE_NAME%
443
444:SPo2k
445if "%O2K_PREC_SP_TARGET_ID%"=="" goto SPoxp
446echo %O2K_PREC_SP_TARGET_ID% >"%TEMP%\MissingUpdateIds.txt"
447call ListUpdatesToInstall.cmd /excludestatics
448if errorlevel 1 goto ListError
449if exist "%TEMP%\UpdatesToInstall.txt" (
450  echo Installing Office 2000 Service Release 1a...
451  call InstallListedUpdates.cmd /errorsaswarnings
452)
453
454:SPoxp
455:SPo2k3
456:SPo2k7
457echo %OFFICE_SP_TARGET_ID% >"%TEMP%\MissingUpdateIds.txt"
458call ListUpdatesToInstall.cmd /excludestatics
459if errorlevel 1 goto ListError
460if not exist "%TEMP%\UpdatesToInstall.txt" goto NoUpdates
461echo Installing most recent Office Service Pack...
462call InstallListedUpdates.cmd
463if errorlevel 1 goto InstError
464set REBOOT_REQUIRED=1
465
466:SkipSPOfc
467
468rem *** Check installation state of Office Converter/Compatibility Packs ***
469if "%INSTALL_CONVERTERS%" NEQ "/instofccnvs" goto CheckAUService
470goto CNV%OFFICE_NAME%
471
472:CNVo2k
473:CNVoxp
474:CNVo2k3
475echo Checking installation state of Office Converter/Compatibility Packs...
476if "%OFFICE_CONVERTER_PACK%" NEQ "1" (
477  if exist %UPDATE_MEDIUM%\ofc\glb\OCONVPCK.EXE (
478    echo Installing Office Converter Pack...
479    echo Installing %UPDATE_MEDIUM%\ofc\glb\OCONVPCK.EXE...
480    %UPDATE_MEDIUM%\ofc\glb\OCONVPCK.EXE /T:"%TEMP%\ocnvpack" /C /Q
481    %SystemRoot%\system32\msiexec.exe /i "%TEMP%\ocnvpack\ocp11.msi" /qn /norestart
482    call SafeRmDir.cmd "%TEMP%\ocnvpack"
483    echo %DATE% %TIME% - Info: Installed %UPDATE_MEDIUM%\ofc\glb\OCONVPCK.EXE >>%UPDATE_LOGFILE%
484  ) else (
485    echo Warning: File %UPDATE_MEDIUM%\ofc\glb\OCONVPCK.EXE not found.
486    echo %DATE% %TIME% - Warning: File %UPDATE_MEDIUM%\ofc\glb\OCONVPCK.EXE not found >>%UPDATE_LOGFILE%
487  )
488)
489if "%OFFICE_COMPATIBILITY_PACK%" NEQ "1" (
490  if exist %UPDATE_MEDIUM%\ofc\%OFFICE_LANGUAGE%\FileFormatConverters.exe (
491    echo Installing Office 2007 Compatibility Pack...
492    call InstallOfficeUpdate.cmd %UPDATE_MEDIUM%\ofc\%OFFICE_LANGUAGE%\FileFormatConverters.exe
493  ) else (
494    echo Warning: File %UPDATE_MEDIUM%\ofc\%OFFICE_LANGUAGE%\FileFormatConverters.exe not found.
495    echo %DATE% %TIME% - Warning: File %UPDATE_MEDIUM%\ofc\%OFFICE_LANGUAGE%\FileFormatConverters.exe not found >>%UPDATE_LOGFILE%
496  )
497  dir /B %UPDATE_MEDIUM%\ofc\%OFFICE_LANGUAGE%\compatibilitypacksp*.exe >nul 2>&1
498  if errorlevel 1 (
499    echo Warning: File %UPDATE_MEDIUM%\ofc\%OFFICE_LANGUAGE%\compatibilitypacksp*.exe not found.
500    echo %DATE% %TIME% - Warning: File %UPDATE_MEDIUM%\ofc\%OFFICE_LANGUAGE%\compatibilitypacksp*.exe not found >>%UPDATE_LOGFILE%
501  ) else (
502    for /F %%i in ('dir /B %UPDATE_MEDIUM%\ofc\%OFFICE_LANGUAGE%\compatibilitypacksp*.exe') do (
503      echo Installing Service Pack 1 for Office 2007 Compatibility Pack...
504      call InstallOfficeUpdate.cmd %UPDATE_MEDIUM%\ofc\%OFFICE_LANGUAGE%\%%i
505    )
506  )
507)
508:CNVo2k7
509
510:CheckAUService
511rem *** Check state of service 'automatic updates' ***
512echo Checking state of service 'automatic updates'...
513echo %DATE% %TIME% - Info: Detected state of service 'automatic updates': %AU_SERVICE_STATE_INITIAL% (start mode: %AU_SERVICE_START_MODE%) >>%UPDATE_LOGFILE%
514if /i "%AU_SERVICE_STATE_INITIAL%"=="" goto ListMissingIds
515if /i "%AU_SERVICE_STATE_INITIAL%"=="Unknown" goto ListMissingIds
516if /i "%AU_SERVICE_STATE_INITIAL%"=="Running" goto ListMissingIds
517if /i "%AU_SERVICE_START_MODE%"=="Disabled" goto AUSvcNotRunning
518echo Starting service 'automatic updates' (wuauserv)...
519%SystemRoot%\system32\net.exe start wuauserv >nul
520if not errorlevel 0 goto AUSvcNotRunning
521set AU_SERVICE_STARTED=1
522echo %DATE% %TIME% - Info: Started service 'automatic updates' (wuauserv) >>%UPDATE_LOGFILE%
523
524:ListMissingIds
525rem *** List ids of missing updates ***
526echo Listing ids of missing updates...
527if not exist %UPDATE_MEDIUM%\wsus\wsusscn2.cab goto NoWSUSScan
528copy /Y %UPDATE_MEDIUM%\wsus\wsusscn2.cab "%TEMP%" >nul
529if exist "%TEMP%\MissingUpdateIds.txt" del "%TEMP%\MissingUpdateIds.txt"
530%CSCRIPT_PATH% //Nologo //E:vbs ListMissingUpdateIds.vbs %LIST_MODE_IDS%
531del "%TEMP%\wsusscn2.cab"
532
533if "%IGNORE_OFFICE%"=="/ignoreoffice" goto ListInstFiles
534if "%OFFICE_NAME%"=="" goto ListInstFiles
535if not exist %UPDATE_MEDIUM%\%OFFICE_NAME%\%OFFICE_LANGUAGE%\. (
536  if not exist %UPDATE_MEDIUM%\%OFFICE_NAME%\glb\. goto ListInstFiles
537)
538rem *** Extract Office inventory packages ***
539echo Extracting Office inventory packages...
540if not exist %UPDATE_MEDIUM%\wsus\invcif.exe (
541  echo Warning: Office inventory catalog file %UPDATE_MEDIUM%\wsus\invcif.exe not found.
542  echo %DATE% %TIME% - Warning: Office inventory catalog file %UPDATE_MEDIUM%\wsus\invcif.exe not found >>%UPDATE_LOGFILE%
543  goto ListInstFiles
544)
545if not exist %UPDATE_MEDIUM%\wsus\invcm.exe (
546  echo Warning: Office inventory tool %UPDATE_MEDIUM%\wsus\invcm.exe not found.
547  echo %DATE% %TIME% - Warning: Office inventory tool %UPDATE_MEDIUM%\wsus\invcm.exe not found >>%UPDATE_LOGFILE%
548  goto ListInstFiles
549)
550if not exist ..\bin\msxsl.exe (
551  echo Warning: Microsoft XSL processor frontend ..\bin\msxsl.exe not found.
552  echo %DATE% %TIME% - Warning: Microsoft XSL processor frontend ..\bin\msxsl.exe not found >>%UPDATE_LOGFILE%
553  goto ListInstFiles
554)
555%UPDATE_MEDIUM%\wsus\invcm.exe /T:"%TEMP%\inventory" /C /Q
556%UPDATE_MEDIUM%\wsus\invcif.exe /T:"%TEMP%\inventory\cifs" /C /Q
557"%TEMP%\inventory\inventory.exe" /s "%TEMP%\inventory\cifs" /o "%TEMP%\inventory\cifs"
558"%TEMP%\inventory\convert.exe" /d "%TEMP%\inventory\cifs" /o "%TEMP%\inventory.xml"
559call SafeRmDir.cmd "%TEMP%\inventory"
560
561rem *** List ids of missing Office updates ***
562echo Listing ids of missing Office updates...
563if "%LIST_MODE_IDS%"=="/all" (
564  ..\bin\msxsl.exe "%TEMP%\inventory.xml" ..\xslt\ExtractAllOfficeUpdateIds.xsl -o "%TEMP%\MissingOfficeUpdateIds.txt"
565) else (
566  ..\bin\msxsl.exe "%TEMP%\inventory.xml" ..\xslt\ExtractMissingOfficeUpdateIds.xsl -o "%TEMP%\MissingOfficeUpdateIds.txt"
567)
568del "%TEMP%\inventory.xml"
569if not exist "%TEMP%\MissingOfficeUpdateIds.txt" goto ListInstFiles
570for %%i in ("%TEMP%\MissingOfficeUpdateIds.txt") do (
571  if "%%~zi"=="0" (
572    del "%TEMP%\MissingOfficeUpdateIds.txt"
573    goto ListInstFiles
574  )
575)
576if exist "%TEMP%\MissingUpdateIds.txt" (
577  %SystemRoot%\system32\findstr.exe /I /V /G:"%TEMP%\MissingOfficeUpdateIds.txt" "%TEMP%\MissingUpdateIds.txt" >"%TEMP%\MissingOSUpdateIds.txt"
578  del "%TEMP%\MissingUpdateIds.txt"
579  ren "%TEMP%\MissingOSUpdateIds.txt" MissingUpdateIds.txt
580)
581for /F "usebackq" %%i in ("%TEMP%\MissingOfficeUpdateIds.txt") do echo %%i>>"%TEMP%\MissingUpdateIds.txt"
582del "%TEMP%\MissingOfficeUpdateIds.txt"
583
584:ListInstFiles
585rem *** List update files ***
586if not exist "%TEMP%\MissingUpdateIds.txt" (
587  if "%REBOOT_REQUIRED%"=="1" (goto Installed) else (goto NoMissingIds)
588)
589echo Listing update files...
590call ListUpdatesToInstall.cmd %LIST_MODE_UPDATES% %IGNORE_OFFICE%
591if errorlevel 1 goto ListError
592
593:InstallUpdates
594rem *** Install updates ***
595if not exist "%TEMP%\UpdatesToInstall.txt" goto NoUpdates
596echo Installing updates...
597call InstallListedUpdates.cmd /selectoptions %BACKUP_MODE% /errorsaswarnings
598if errorlevel 1 goto InstError
599
600:Installed
601if "%RECALL_REQUIRED%"=="1" (
602  if "%BOOT_MODE%"=="/autoreboot" (
603    if not "%USERNAME%"=="WSUSUpdateAdmin" (
604      echo Preparing automatic recall...
605      call PrepareRecall.cmd %~f0 %BACKUP_MODE% %INSTALL_IE7% %INSTALL_DOTNET% %IGNORE_OFFICE% %INSTALL_CONVERTERS% %BOOT_MODE% %SHOW_LOG% %LIST_MODE_IDS% %LIST_MODE_UPDATES%
606    )
607    echo Rebooting...
608    %CSCRIPT_PATH% //Nologo //E:vbs Reboot.vbs
609  ) else (
610    echo.
611    echo Installation successful. Please reboot your system now and recall Update afterwards.
612    echo %DATE% %TIME% - Info: Installation successful >>%UPDATE_LOGFILE%
613    echo.
614REM ### 20090313 Start
615        %CSCRIPT_PATH% //Nologo //E:vbs Reboot.vbs
616REM ### 20090313 Ende
617  )
618) else (
619  if "%SHOW_LOG%"=="/showlog" call PrepareShowLogFile.cmd
620  if "%BOOT_MODE%"=="/autoreboot" (
621    if "%USERNAME%"=="WSUSUpdateAdmin" (
622      echo Cleaning up automatic recall...
623      call CleanupRecall.cmd
624      del /Q "%TEMP%\wsusadmin-recall.*"
625    )
626    echo Rebooting...
627    %CSCRIPT_PATH% //Nologo //E:vbs Reboot.vbs
628  ) else (
629    echo.
630    echo Installation successful. Please reboot your system now.
631    echo %DATE% %TIME% - Info: Installation successful >>%UPDATE_LOGFILE%
632    echo.
633REM ### 20090313 Start
634        %CSCRIPT_PATH% //Nologo //E:vbs Reboot.vbs
635REM ### 20090313 Ende
636  )
637)
638goto EoF
639
640:NoExtensions
641echo.
642echo ERROR: No command extensions available.
643echo.
644exit /b 1
645
646:NoTemp
647echo.
648echo ERROR: Environment variable TEMP not set.
649echo %DATE% %TIME% - Error: Environment variable TEMP not set >>%UPDATE_LOGFILE%
650echo.
651goto Cleanup
652
653:NoTempDir
654echo.
655echo ERROR: Directory "%TEMP%" not found.
656echo %DATE% %TIME% - Error: Directory "%TEMP%" not found >>%UPDATE_LOGFILE%
657echo.
658goto Cleanup
659
660:NoCScript
661echo.
662echo ERROR: VBScript interpreter %CSCRIPT_PATH% not found.
663echo %DATE% %TIME% - Error: VBScript interpreter %CSCRIPT_PATH% not found >>%UPDATE_LOGFILE%
664echo.
665goto Cleanup
666
667:NoReg
668echo.
669echo ERROR: Registry tool %REG_PATH% not found.
670echo %DATE% %TIME% - Error: Registry tool %REG_PATH% not found >>%UPDATE_LOGFILE%
671echo.
672goto Cleanup
673
674:EndlessLoop
675echo.
676echo ERROR: Potentially endless reboot/recall loop detected.
677echo %DATE% %TIME% - Error: Potentially endless reboot/recall loop detected >>%UPDATE_LOGFILE%
678echo.
679goto Cleanup
680
681:NoSysEnvVars
682echo.
683echo ERROR: Determination of OS properties failed.
684echo %DATE% %TIME% - Error: Determination of OS properties failed >>%UPDATE_LOGFILE%
685echo.
686goto Cleanup
687
688:UnsupLang
689echo.
690echo ERROR: Unsupported Operating System language.
691echo %DATE% %TIME% - Error: Unsupported Operating System language >>%UPDATE_LOGFILE%
692echo.
693goto Cleanup
694
695:NoOSName
696echo.
697echo ERROR: Environment variable OS_NAME not set.
698echo %DATE% %TIME% - Error: Environment variable OS_NAME not set >>%UPDATE_LOGFILE%
699echo.
700goto Cleanup
701
702:UnsupArch
703echo.
704echo ERROR: Unsupported Operating System architecture (%OS_ARCHITECTURE%).
705echo %DATE% %TIME% - Error: Unsupported Operating System architecture (%OS_ARCHITECTURE%) >>%UPDATE_LOGFILE%
706echo.
707goto Cleanup
708
709:UnsupSP
710echo.
711echo ERROR: Unsupported Operating System Service Pack level (%OS_NAME% sp%OS_SP_VERSION_MAJOR%).
712echo %DATE% %TIME% - Error: Unsupported Operating System Service Pack level (%OS_NAME% sp%OS_SP_VERSION_MAJOR%) >>%UPDATE_LOGFILE%
713echo.
714goto Cleanup
715
716:NoAutoReboot
717echo.
718echo ERROR: Switch /autoreboot is unsupported on domain controllers.
719echo %DATE% %TIME% - Error: Switch /autoreboot is unsupported on domain controllers >>%UPDATE_LOGFILE%
720echo.
721goto Cleanup
722
723:NoIfAdmin
724echo.
725echo ERROR: File ..\bin\IfAdmin.exe not found.
726echo %DATE% %TIME% - Error: File ..\bin\IfAdmin.exe not found >>%UPDATE_LOGFILE%
727echo.
728goto Cleanup
729
730:NoAdmin
731echo.
732echo ERROR: User %USERNAME% does not have administrative privileges.
733echo %DATE% %TIME% - Error: User %USERNAME% does not have administrative privileges >>%UPDATE_LOGFILE%
734echo.
735goto EoF
736
737:InvalidMedium
738echo.
739echo ERROR: Medium neither supports your Windows nor your Office version.
740echo %DATE% %TIME% - Error: Medium neither supports your Windows nor your Office version >>%UPDATE_LOGFILE%
741echo.
742goto Cleanup
743
744:NoWUAInst
745echo.
746echo ERROR: File %WUA_FILENAME% not found.
747echo %DATE% %TIME% - Error: File %WUA_FILENAME% not found >>%UPDATE_LOGFILE%
748echo.
749goto Cleanup
750
751:NoSPTargetId
752echo.
753echo ERROR: Environment variable OS_SP_TARGET_ID not set.
754echo %DATE% %TIME% - Error: Environment variable OS_SP_TARGET_ID not set >>%UPDATE_LOGFILE%
755echo.
756goto Cleanup
757
758:AUSvcNotRunning
759echo.
760echo ERROR: Service 'automatic updates' (wuauserv) is not running and could not be started.
761echo %DATE% %TIME% - Error: Service 'automatic updates' (wuauserv) is not running and could not be started >>%UPDATE_LOGFILE%
762echo.
763goto Cleanup
764
765:NoWSUSScan
766echo.
767echo ERROR: File %UPDATE_MEDIUM%\wsus\wsusscn2.cab not found.
768echo %DATE% %TIME% - Error: File %UPDATE_MEDIUM%\wsus\wsusscn2.cab not found >>%UPDATE_LOGFILE%
769echo.
770goto Cleanup
771
772:NoMissingIds
773echo.
774echo No missing updates found. Nothing to do!
775echo %DATE% %TIME% - Info: No missing updates found >>%UPDATE_LOGFILE%
776echo.
777goto Cleanup
778
779:NoUpdates
780echo.
781echo Warning: Any missing update was either black listed or not found.
782echo %DATE% %TIME% - Warning: Any missing update was either black listed or not found >>%UPDATE_LOGFILE%
783echo.
784goto Cleanup
785
786:ListError
787echo.
788echo ERROR: Listing of update files failed.
789echo %DATE% %TIME% - Error: Listing of update files failed >>%UPDATE_LOGFILE%
790echo.
791goto Cleanup
792
793:InstError
794echo.
795echo ERROR: Installation failed.
796echo %DATE% %TIME% - Error: Installation failed >>%UPDATE_LOGFILE%
797echo.
798goto Cleanup
799
800:Cleanup
801if "%USERNAME%"=="WSUSUpdateAdmin" (
802  if "%SHOW_LOG%"=="/showlog" call PrepareShowLogFile.cmd
803  echo Cleaning up automatic recall...
804  call CleanupRecall.cmd
805  del /Q "%TEMP%\wsusadmin-recall.*"
806  echo Rebooting...
807  %CSCRIPT_PATH% //Nologo //E:vbs Reboot.vbs
808) else (
809  if "%AU_SERVICE_STARTED%"=="1" (
810    echo Stopping service 'automatic updates' ^(wuauserv^)...
811    %SystemRoot%\system32\net.exe stop wuauserv >.
812    if errorlevel 0 (
813      echo %DATE% %TIME% - Info: Stopped service 'automatic updates' ^(wuauserv^) >>%UPDATE_LOGFILE%
814    ) else (
815      echo %DATE% %TIME% - Warning: Stopping of service 'automatic updates' ^(wuauserv^) failed >>%UPDATE_LOGFILE%
816    )
817  )
818  if "%SHOW_LOG%"=="/showlog" start %SystemRoot%\system32\notepad.exe %UPDATE_LOGFILE%
819)
820goto EoF
821
822:EoF
823cd ..
824echo %DATE% %TIME% - Info: Ending update >>%UPDATE_LOGFILE%
825title %ComSpec%
826if "%RECALL_REQUIRED%"=="1" verify other 2>nul
827endlocal
828exit