Advertisement
shornby

Create Win to Go via script-Need Win8 ADK.cmd

Jun 15th, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 16.53 KB | None | 0 0
  1. ECHO OFF
  2. REM *****************************************************************************************************
  3. REM ** Microsoft Windows To Go Sample BatchFile provisioning script.
  4. REM **
  5. REM ** This script is designed to be used from an elevated command prompt on a computer that is running either Windows 8 or Windows 7 with the Windows 8 ADK
  6. REM ** The script will provision 1 USB drive for Windows To Go (WTG)
  7. REM **
  8. REM ** User must supply the ID for the USB device to become a WTG drive.
  9. REM ** User must supply the path to the install image.
  10. REM ** User must have DISM.exe version 6.2.9200.16384 and dependencies from the win8 ADK
  11. REM **
  12. REM *****************************************************************************************************
  13.  
  14. if "%1" equ "" goto help
  15. if %1 LSS 1 goto InvalidDrive
  16. if "%2" equ "" goto help
  17.  
  18. REM Create SanPolicy unattend file.
  19. echo ^<?xml version="1.0" encoding="utf-8" standalone="yes"?^>                     > San_Policy.xml
  20. echo ^<unattend xmlns="urn:schemas-microsoft-com:unattend"^>                       >> San_Policy.xml
  21. echo   ^<settings pass="offlineServicing"^>                                        >> San_Policy.xml
  22. echo     ^<component                                                               >> San_Policy.xml
  23. echo         xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"         >> San_Policy.xml
  24. echo         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                 >> San_Policy.xml
  25. echo         language="neutral"                                                    >> San_Policy.xml
  26. echo         name="Microsoft-Windows-PartitionManager"                             >> San_Policy.xml
  27. echo         processorArchitecture="amd64"                                         >> San_Policy.xml
  28. echo         publicKeyToken="31bf3856ad364e35"                                     >> San_Policy.xml
  29. echo         versionScope="nonSxS"                                                 >> San_Policy.xml
  30. echo         ^>                                                                    >> San_Policy.xml
  31. echo       ^<SanPolicy^>4^</SanPolicy^>                                            >> San_Policy.xml
  32. echo     ^</component^>                                                            >> San_Policy.xml
  33. echo     ^<component                                                               >> San_Policy.xml
  34. echo         xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"         >> San_Policy.xml
  35. echo         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                 >> San_Policy.xml
  36. echo         language="neutral"                                                    >> San_Policy.xml
  37. echo         name="Microsoft-Windows-PartitionManager"                             >> San_Policy.xml
  38. echo         processorArchitecture="x86"                                           >> San_Policy.xml
  39. echo         publicKeyToken="31bf3856ad364e35"                                     >> San_Policy.xml
  40. echo         versionScope="nonSxS"                                                 >> San_Policy.xml
  41. echo         ^>                                                                    >> San_Policy.xml
  42. echo       ^<SanPolicy^>4^</SanPolicy^>                                            >> San_Policy.xml
  43. echo     ^</component^>                                                            >> San_Policy.xml
  44. echo   ^</settings^>                                                               >> San_Policy.xml
  45. echo ^</unattend^>                                                                 >> San_Policy.xml
  46.  
  47. REM Create a generic OOBE unattend file.
  48. echo ^<?xml version="1.0" encoding="utf-8"?^>                                                                                                                                                                                                                                                         > unattend.xml
  49. echo ^<unattend xmlns="urn:schemas-microsoft-com:unattend"^>                                                                                                                                                                                                                                          >> unattend.xml
  50. echo     ^<settings pass="oobeSystem"^>                                                                                                                                                                                                                                                               >> unattend.xml
  51. echo         ^<component name="Microsoft-Windows-Shell-Setup" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="AMD64" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"^>          >> unattend.xml
  52. echo             ^<OOBE^>                                                                                                                                                                                                                                                                             >> unattend.xml
  53. echo                 ^<HideEULAPage^>true^</HideEULAPage^>                                                                                                                                                                                                                                            >> unattend.xml
  54. echo                 ^<ProtectYourPC^>1^</ProtectYourPC^>                                                                                                                                                                                                                                             >> unattend.xml
  55. echo                 ^<NetworkLocation^>Work^</NetworkLocation^>                                                                                                                                                                                                                                      >> unattend.xml
  56. echo             ^</OOBE^>                                                                                                                                                                                                                                                                            >> unattend.xml
  57. echo         ^</component^>                                                                                                                                                                                                                                                                           >> unattend.xml
  58. echo         ^<component name="Microsoft-Windows-International-Core" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="AMD64"^>                                                                                                                       >> unattend.xml
  59. echo           ^<InputLocale^>en-US^</InputLocale^>                                                                                                                                                                                                                                                   >> unattend.xml
  60. echo           ^<SystemLocale^>en-US^</SystemLocale^>                                                                                                                                                                                                                                                 >> unattend.xml
  61. echo           ^<UILanguage^>en-US^</UILanguage^>                                                                                                                                                                                                                                                     >> unattend.xml
  62. echo           ^<UserLocale^>en-US^</UserLocale^>                                                                                                                                                                                                                                                     >> unattend.xml
  63. echo         ^</component^>                                                                                                                                                                                                                                                                           >> unattend.xml
  64. echo         ^<component name="Microsoft-Windows-WinRE-RecoveryAgent" 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"^>  >> unattend.xml
  65. echo             ^<UninstallWindowsRE^>true^</UninstallWindowsRE^>                                                                                                                                                                                                                                    >> unattend.xml
  66. echo         ^</component^>                                                                                                                                                                                                                                                                           >> unattend.xml
  67. echo         ^<component name="Microsoft-Windows-Shell-Setup" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="X86" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"^>            >> unattend.xml
  68. echo             ^<OOBE^>                                                                                                                                                                                                                                                                             >> unattend.xml
  69. echo                 ^<HideEULAPage^>true^</HideEULAPage^>                                                                                                                                                                                                                                            >> unattend.xml
  70. echo                 ^<ProtectYourPC^>1^</ProtectYourPC^>                                                                                                                                                                                                                                             >> unattend.xml
  71. echo                 ^<NetworkLocation^>Work^</NetworkLocation^>                                                                                                                                                                                                                                      >> unattend.xml
  72. echo             ^</OOBE^>                                                                                                                                                                                                                                                                            >> unattend.xml
  73. echo         ^</component^>                                                                                                                                                                                                                                                                           >> unattend.xml
  74. echo         ^<component name="Microsoft-Windows-International-Core" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="x86"^>                                                                                                                         >> unattend.xml
  75. echo           ^<InputLocale^>en-US^</InputLocale^>                                                                                                                                                                                                                                                   >> unattend.xml
  76. echo           ^<SystemLocale^>en-US^</SystemLocale^>                                                                                                                                                                                                                                                 >> unattend.xml
  77. echo           ^<UILanguage^>en-US^</UILanguage^>                                                                                                                                                                                                                                                     >> unattend.xml
  78. echo           ^<UserLocale^>en-US^</UserLocale^>                                                                                                                                                                                                                                                     >> unattend.xml
  79. echo         ^</component^>                                                                                                                                                                                                                                                                           >> unattend.xml
  80. echo         ^<component name="Microsoft-Windows-WinRE-RecoveryAgent" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"^>    >> unattend.xml
  81. echo             ^<UninstallWindowsRE^>true^</UninstallWindowsRE^>                                                                                                                                                                                                                                    >> unattend.xml
  82. echo         ^</component^>                                                                                                                                                                                                                                                                           >> unattend.xml
  83. echo     ^</settings^>                                                                                                                                                                                                                                                                                >> unattend.xml
  84. echo ^</unattend^>                                                                                                                                                                                                                                                                                    >> unattend.xml
  85.  
  86.  
  87. REM Create DiskPart Commands for cleaning and creating a WTG MBR
  88. REM formatted device.  This will create 2 partitions for BIOS & UEFI
  89. REM roaming and set the NoDefaultDriveLetter attribute.
  90. echo select disk %1                             > cmds.txt
  91. echo clean                                      >> cmds.txt
  92. echo create partition primary size=350          >> cmds.txt
  93. echo active                                     >> cmds.txt
  94. echo format FS=FAT32 quick LABEL="WTG-SYSTEM"   >> cmds.txt
  95. echo assign letter=S                            >> cmds.txt
  96. echo create partition primary                   >> cmds.txt
  97. echo format FS=NTFS quick LABEL="WTG-WINDOWS"   >> cmds.txt
  98. echo assign letter=W                            >> cmds.txt
  99. echo attributes volume set NODEFAULTDRIVELETTER >> cmds.txt
  100.  
  101. diskpart /s cmds.txt
  102. del cmds.txt
  103.  
  104. REM Apply the image from the command line.
  105. dism /apply-image /index:1 /applydir:w:\ /imagefile:%2
  106.  
  107. REM Change the boot sector from Windows 7 to Windows 8
  108. w:\windows\system32\bootsect.exe /nt60 S:
  109.  
  110. REM We're running bcdboot from the newly applied image so we know that the correct boot files for the architecture and operating system are used.
  111. w:\windows\system32\bcdboot.exe W:\windows /F ALL /s S:
  112.  
  113. REM Apply SAN policy and configure the default unattend file.
  114. dism /image:w:\ /apply-unattend:San_Policy.xml
  115. copy  unattend.xml w:\windows\System32\sysprep\unattend.xml
  116.  
  117. del San_Policy.xml
  118. del unattend.xml
  119.  
  120. goto end
  121.  
  122. :InvalidDrive
  123. ECHO ERROR: do not specify the boot drive (ID 0), this would erase the current drive.
  124.  
  125. :help
  126. ECHO Usage WTG_WIN7_Provision.cmd ^<USB DiskId^> ^<PathToWim^>
  127. ECHO
  128. ECHO Example: WTG_WIN7_Provision.cmd 1 .\9200_x86fre_ent.wim
  129. :end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement