Skip to content

Commit 780b0e8

Browse files
author
Mischa Taylor
committedDec 13, 2014
Experiment with automatically updating Windows Update for w2k8r2/win7
Success criteria is that the box no longer prompts for Windows update to be updated when launching Windows Update for the first time. Needs to be in Autounattend.xml rather than in scripts as the install requires a tty/message pump.
1 parent 466a571 commit 780b0e8

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
 

‎eval-win2008r2-datacenter.json

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"floppy/passwordchange.bat",
3030
"floppy/openssh.bat",
3131
"floppy/disablewinupdate.bat",
32+
"floppy/upgrade-wua.bat",
3233
"floppy/zz-start-sshd.cmd"
3334
],
3435
"tools_upload_flavor": "windows",
@@ -61,6 +62,7 @@
6162
"floppy/passwordchange.bat",
6263
"floppy/openssh.bat",
6364
"floppy/disablewinupdate.bat",
65+
"floppy/upgrade-wua.bat",
6466
"floppy/zz-start-sshd.cmd",
6567
"floppy/oracle-cert.cer"
6668
],
@@ -83,6 +85,7 @@
8385
],
8486
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
8587
"scripts": [
88+
"script/update.bat",
8689
"script/vagrant.bat",
8790
"script/cmtool.bat",
8891
"script/vmtool.bat",

‎eval-win7x64-enterprise.json

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"floppy/networkprompt.bat",
3232
"floppy/disablewinupdate.bat",
3333
"floppy/openssh.bat",
34+
"floppy/upgrade-wua.bat",
3435
"floppy/zz-start-sshd.cmd"
3536
],
3637
"tools_upload_flavor": "windows",
@@ -67,6 +68,7 @@
6768
"floppy/networkprompt.bat",
6869
"floppy/disablewinupdate.bat",
6970
"floppy/openssh.bat",
71+
"floppy/upgrade-wua.bat",
7072
"floppy/zz-start-sshd.cmd",
7173
"floppy/oracle-cert.cer"
7274
],
@@ -89,6 +91,7 @@
8991
],
9092
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
9193
"scripts": [
94+
"script/update.bat",
9295
"script/vagrant.bat",
9396
"script/cmtool.bat",
9497
"script/vmtool.bat",

‎floppy/upgrade-wua.bat

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@setlocal EnableDelayedExpansion EnableExtensions
2+
@for %%i in (%~dp0\_packer_config*.cmd) do @call "%%~i"
3+
@if defined PACKER_DEBUG (@echo on) else (@echo off)
4+
5+
title Upgrading Windows Upgrade Agent. Please wait...
6+
7+
if not defined WUA_64_URL set WUA_64_URL=http://download.windowsupdate.com/windowsupdate/redist/standalone/7.6.7600.320/WindowsUpdateAgent-7.6-x64.exe
8+
if not defined WUA_32_URL set WUA_32_URL=http://download.windowsupdate.com/windowsupdate/redist/standalone/7.6.7600.320/WindowsUpdateAgent-7.6-x86.exe
9+
10+
if defined ProgramFiles(x86) (
11+
set WUA_URL=%WUA_64_URL%
12+
) else (
13+
set WUA_URL=%WUA_32_URL%
14+
)
15+
16+
for %%i in (%WUA_URL%) do set WUA_EXE=%%~nxi
17+
set WUA_DIR=%TEMP%\wua
18+
set WUA_PATH=%WUA_DIR%\%WUA_EXE%
19+
20+
echo ==^> Creating "%WUA_DIR%"
21+
mkdir "%WUA_DIR%"
22+
23+
if exist "%SystemRoot%\_download.cmd" (
24+
call "%SystemRoot%\_download.cmd" "%WUA_URL%" "%WUA_PATH%"
25+
) else (
26+
echo ==^> Downloading "%WUA_URL%" to "%WUA_PATH%"
27+
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%WUA_URL%', '%WUA_PATH%')" <NUL
28+
)
29+
if not exist "%WUA_PATH%" goto exit1
30+
31+
echo ==^> Upgrading Windows Update Agent
32+
"%WUA_PATH%" /quiet
33+
34+
echo ==^> Removing "%WUA_DIR%"
35+
rmdir /q /s "%WUA_DIR%"
36+
37+
:exit0
38+
ver>nul
39+
goto :exit
40+
41+
:exit1
42+
verify other 2>nul
43+
44+
:exit

0 commit comments

Comments
 (0)
Please sign in to comment.