Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

Win sysprep #36

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions eval-win10x64-enterprise.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"iso_url": "http://iso.esd.microsoft.com/W9TPI/B6B0A0278A90510669EAB90ABF80B22A/Windows10_TechnicalPreview_x64_EN-US_9926.iso",
"iso_checksum": "6a95316728299d95249a29fbeb9676ded23b8beb",
"update": true,
"sysprep": "true",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c 'Packer Shutdown'"
},
"builders": [
Expand All @@ -21,6 +22,7 @@
"ssh_wait_timeout": "10000s",
"floppy_files": [
"floppy/eval-win10x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/powerconfig.bat",
Expand Down Expand Up @@ -55,6 +57,7 @@
"ssh_wait_timeout": "10000s",
"floppy_files": [
"floppy/eval-win10x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/powerconfig.bat",
Expand Down Expand Up @@ -88,6 +91,7 @@
"ssh_wait_timeout": "10000s",
"floppy_files": [
"floppy/eval-win10x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/powerconfig.bat",
Expand Down Expand Up @@ -116,7 +120,8 @@
"environment_vars": [
"CM={{user `cm`}}",
"CM_VERSION={{user `cm_version`}}",
"UPDATE={{user `update`}}"
"UPDATE={{user `update`}}",
"SYSPREP={{user `sysprep`}}"
],
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
Expand All @@ -126,7 +131,8 @@
"script/clean.bat",
"script/ultradefrag.bat",
"script/uninstall-7zip.bat",
"script/sdelete.bat"
"script/sdelete.bat",
"script/sysprep-generalize.bat"
]
},
{
Expand Down
12 changes: 9 additions & 3 deletions eval-win7x64-enterprise.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"iso_url": "http://care.dlservice.microsoft.com/dl/download/evalx/win7/x64/EN/7600.16385.090713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso",
"iso_checksum": "15ddabafa72071a06d5213b486a02d5b55cb7070",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c 'Packer Shutdown'",
"update": true
"update": true,
"sysprep": "true"
},
"builders": [
{
Expand All @@ -20,6 +21,7 @@
"ssh_password": "vagrant",
"floppy_files": [
"floppy/win7x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/fixnetwork.ps1",
Expand Down Expand Up @@ -57,6 +59,7 @@
"disk_size": 40960,
"floppy_files": [
"floppy/win7x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/fixnetwork.ps1",
Expand Down Expand Up @@ -92,6 +95,7 @@
"disk_size": 40960,
"floppy_files": [
"floppy/win7x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/fixnetwork.ps1",
Expand Down Expand Up @@ -122,7 +126,8 @@
"environment_vars": [
"CM={{user `cm`}}",
"CM_VERSION={{user `cm_version`}}",
"UPDATE={{user `update`}}"
"UPDATE={{user `update`}}",
"SYSPREP={{user `sysprep`}}"
],
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
Expand All @@ -132,7 +137,8 @@
"script/clean.bat",
"script/ultradefrag.bat",
"script/uninstall-7zip.bat",
"script/sdelete.bat"
"script/sdelete.bat",
"script/sysprep-generalize.bat"
]
},
{
Expand Down
11 changes: 8 additions & 3 deletions eval-win81x64-enterprise.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"iso_url": "http://download.microsoft.com/download/B/9/9/B999286E-0A47-406D-8B3D-5B5AD7373A4A/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_ENTERPRISE_EVAL_EN-US-IRM_CENA_X64FREE_EN-US_DV5.ISO",
"iso_checksum": "73321fa912305e5a16096ef62380a91ee1f112da",
"update": true,
"sysprep": "false",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c 'Packer Shutdown'"
},
"builders": [
Expand All @@ -21,6 +22,7 @@
"ssh_wait_timeout": "10000s",
"floppy_files": [
"floppy/eval-win81x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/powerconfig.bat",
Expand Down Expand Up @@ -55,14 +57,14 @@
"ssh_wait_timeout": "10000s",
"floppy_files": [
"floppy/eval-win81x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/powerconfig.bat",
"floppy/01-install-wget.cmd",
"floppy/_download.cmd",
"floppy/_packer_config.cmd",
"floppy/passwordchange.bat",
"floppy/update.bat",
"floppy/disablewinupdate.bat",
"floppy/openssh.bat",
"floppy/zz-start-sshd.cmd",
Expand All @@ -88,6 +90,7 @@
"ssh_wait_timeout": "10000s",
"floppy_files": [
"floppy/eval-win81x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/powerconfig.bat",
Expand Down Expand Up @@ -116,7 +119,8 @@
"environment_vars": [
"CM={{user `cm`}}",
"CM_VERSION={{user `cm_version`}}",
"UPDATE={{user `update`}}"
"UPDATE={{user `update`}}",
"SYSPREP={{user `sysprep`}}"
],
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
Expand All @@ -126,7 +130,8 @@
"script/clean.bat",
"script/ultradefrag.bat",
"script/uninstall-7zip.bat",
"script/sdelete.bat"
"script/sdelete.bat",
"script/sysprep-generalize.bat"
]
},
{
Expand Down
37 changes: 37 additions & 0 deletions floppy/sysprep/unattend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OOBE>
<NetworkLocation>Work</NetworkLocation>
<ProtectYourPC>3</ProtectYourPC>
<HideEULAPage>true</HideEULAPage>
</OOBE>
<UserAccounts>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Password>
<Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value>
<PlainText>false</PlainText>
</Password>
<Group>Administrators</Group>
<Name>vagrant</Name>
<DisplayName>vagrant</DisplayName>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
<TimeZone>Pacific Standard Time</TimeZone>
</component>
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UserLocale>en-US</UserLocale>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComputerName>*</ComputerName>
</component>
</settings>
</unattend>
44 changes: 44 additions & 0 deletions script/sysprep-generalize.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@echo OFF
@echo ==^> Running sysprep if requested in template file...
@if not defined sysprep (
@echo ==^> No sysprep variable defined, exiting
@goto :eof
)
@echo %SYSPREP% | findstr /I "true"
@if errorlevel 1 (
@echo ==^> Sysprep variable not set to true, exiting
@goto :eof
)
@echo ==^> Copying unattend.xml to sysprep directory
@copy /Y A:\unattend.xml %WINDIR%\system32\sysprep
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: COPY command

@echo ==^> Running sysprep /oobe /generalize with unattend.xml file
@pushd %WINDIR%\system32\sysprep

:: Credit to http://stackoverflow.com/questions/4808847/how-to-compare-windows-versions-in-a-batch-script
@set Version=
@for /f "skip=1" %%v in ('wmic os get version') do if not defined Version set Version=%%v
@for /f "delims=. tokens=1-3" %%a in ("%Version%") do (
@set Version.Major=%%a
@set Version.Minor=%%b
@set Version.Build=%%c
)
@echo ==^> Checking OS Version for sysprep command parameters
@if %Version.Major% GEQ 7 goto :modevm
@if %Version.Major% EQU 6 if %Version.Minor% GEQ 2 goto :modevm
@if %Version.Major% EQU 6 if %Version.Minor% LEQ 1 goto :generalize

:modevm
@echo ==^> Windows 8 Kernel or higher found, supports /mode:vm
sysprep.exe /oobe /generalize /mode:vm /quit
@goto :eof

:generalize
@echo ==^> Windows 7 Kernel found
sysprep.exe /oobe /generalize /quit
@goto :eof

:eof
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: sysprep.exe
@exit /b %ERRORLEVEL%
14 changes: 10 additions & 4 deletions win7x64-enterprise.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"cm_version": "",
"iso_url": "http://care.dlservice.microsoft.com/dl/download/evalx/win7/x64/EN/7600.16385.090713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso",
"iso_checksum": "15ddabafa72071a06d5213b486a02d5b55cb7070",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c 'Packer Shutdown'",
"update": true
"update": true,
"sysprep": "true",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c 'Packer Shutdown'"
},
"builders": [
{
Expand All @@ -20,6 +21,7 @@
"ssh_password": "vagrant",
"floppy_files": [
"floppy/win7x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/fixnetwork.ps1",
Expand Down Expand Up @@ -55,6 +57,7 @@
"disk_size": 40960,
"floppy_files": [
"floppy/win7x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/fixnetwork.ps1",
Expand Down Expand Up @@ -88,6 +91,7 @@
"disk_size": 40960,
"floppy_files": [
"floppy/win7x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/fixnetwork.ps1",
Expand Down Expand Up @@ -116,7 +120,8 @@
"environment_vars": [
"CM={{user `cm`}}",
"CM_VERSION={{user `cm_version`}}",
"UPDATE={{user `update`}}"
"UPDATE={{user `update`}}",
"SYSPREP={{user `sysprep`}}"
],
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
Expand All @@ -126,7 +131,8 @@
"script/clean.bat",
"script/ultradefrag.bat",
"script/uninstall-7zip.bat",
"script/sdelete.bat"
"script/sdelete.bat",
"script/sysprep-generalize.bat"
]
},
{
Expand Down
23 changes: 14 additions & 9 deletions win81x64-enterprise.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"version": "0.1.0",
"cm": "chef",
"cm_version": "",
"iso_url": "iso/en_windows_8.1_enterprise_with_update_x64_dvd_4065178.iso",
"iso_checksum": "8fb332a827998f807a1346bef55969c6519668b9",
"iso_url": "./iso/SW_DVD5_SA_Win_Ent_8.1_64BIT_English_MLF_X18-96759.ISO",
"iso_checksum": "8e194185fcce4ea737f274ee9005ddf0",
"update": true,
"sysprep": "true",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c 'Packer Shutdown'"
},
"builders": [
Expand All @@ -15,12 +16,13 @@
"guest_os_type": "windows8-64",
"iso_url": "{{ user `iso_url` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_checksum_type": "sha1",
"iso_checksum_type": "md5",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "10000s",
"floppy_files": [
"floppy/win81x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/powerconfig.bat",
Expand All @@ -47,12 +49,13 @@
"guest_os_type": "Windows8_64",
"iso_url": "{{ user `iso_url` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_checksum_type": "sha1",
"iso_checksum_type": "md5",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "10000s",
"floppy_files": [
"floppy/win81x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/powerconfig.bat",
Expand All @@ -67,7 +70,7 @@
"shutdown_command": "{{ user `shutdown_command`}}",
"disk_size": 40960,
"vboxmanage": [
["modifyvm", "{{.Name}}", "--memory", "1536"],
["modifyvm", "{{.Name}}", "--memory", "2048"],
["modifyvm", "{{.Name}}", "--cpus", "1"],
["setextradata", "{{.Name}}", "VBoxInternal/CPUM/CMPXCHG16B", "1"]
]
Expand All @@ -78,12 +81,13 @@
"guest_os_type": "win-8.1",
"iso_url": "{{ user `iso_url` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_checksum_type": "sha1",
"iso_checksum_type": "md5",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "10000s",
"floppy_files": [
"floppy/win81x64-enterprise/Autounattend.xml",
"floppy/sysprep/unattend.xml",
"floppy/00-run-all-scripts.cmd",
"floppy/install-winrm.cmd",
"floppy/powerconfig.bat",
Expand All @@ -110,17 +114,18 @@
"environment_vars": [
"CM={{user `cm`}}",
"CM_VERSION={{user `cm_version`}}",
"UPDATE={{user `update`}}"
"UPDATE={{user `update`}}",
"SYSPREP={{user `sysprep`}}"
],
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"script/vagrant.bat",
"script/cmtool.bat",
"script/vmtool.bat",
"script/clean.bat",
"script/ultradefrag.bat",
"script/uninstall-7zip.bat",
"script/sdelete.bat"
"script/sdelete.bat",
"script/sysprep-generalize.bat"
]
},
{
Expand Down
Loading