Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

292 lines
6.6 KiB

  1. rem
  2. rem Determine the directory that this file was executed from. The
  3. rem %~p0 is supposed to return the path less the file name, however
  4. rem if a UNC path was used it also strips the leading "\\".
  5. rem
  6. rem The following hack is to check for this and put the "\\" back
  7. rem if necessary.
  8. rem
  9. setlocal enabledelayedexpansion
  10. if "%1"=="runninglocalcopy" goto :runninglocalcopy
  11. set BINDIR=%~p0
  12. if "%BINDIR%files.cmd"=="%0" goto :gotbindir
  13. set BINDIR=\\%BINDIR%
  14. :gotbindir
  15. set SDXROOT=%BINDIR%\..\..\..
  16. set SXSOFFLINEINSTALL=%SDXROOT%\tools\x86\sxsofflineinstall.exe
  17. copy %BINDIR%\files.cmd . 1>NUL 2>NUL
  18. call files.cmd runninglocalcopy %1 %2 %3 %4 %5 %6 %7 %8 %9
  19. erase files.cmd
  20. goto :eof
  21. :runninglocalcopy
  22. set _TEMPLATE_FILE=%BINDIR%\files.template
  23. shift
  24. if "%1"=="setup" %BINDIR%\setup.cmd
  25. rem
  26. rem Five variables are required to be set at this point:
  27. rem
  28. rem IMAGE_DRIVE
  29. rem IMAGE_PATH
  30. rem SOURCE_1
  31. rem
  32. if "%IMAGE_DRIVE%"=="" goto usage
  33. if "%IMAGE_PATH%"=="" goto usage
  34. if "%SOURCE_1%"=="" goto usage
  35. set SOURCE_2=%BINDIR%\bins
  36. set SOURCE_32=%SOURCE_1%
  37. set SOURCE_WOW64=%SOURCE_1%\wowbins
  38. echo.
  39. echo Binary file source: %BINDIR%
  40. echo Primary file source: %SOURCE_1%
  41. echo Secondary file source: %SOURCE_2%
  42. echo 32-bit loader source: %SOURCE_32%
  43. echo Image drive: %IMAGE_DRIVE%
  44. echo Image path: %IMAGE_PATH%
  45. echo Template file: %_TEMPLATE_FILE%
  46. echo.
  47. set _TARGET_FILE=
  48. set _FP=%1
  49. if "%_FP%"=="sxs" goto copysxs
  50. if "%_FP%"=="settings" goto copydocumentsandsettings
  51. if "%_FP%"=="" goto newtree
  52. rem **********************************************************************
  53. rem
  54. rem Just copy one file
  55. rem
  56. rem **********************************************************************
  57. set _TARGET_FILE=%_FP%
  58. find /I "%_FP%" %_TEMPLATE_FILE% > files.temp.template
  59. set _TEMPLATE_FILE=files.temp.template
  60. goto justonefile
  61. rem **********************************************************************
  62. rem
  63. rem Rebuild the entire tree
  64. rem
  65. rem **********************************************************************
  66. :newtree
  67. echo Deleting target tree...
  68. rd %IMAGE_DRIVE%\windows /s /q
  69. rd "%IMAGE_DRIVE%\documents and settings" /s /q
  70. erase files.missing
  71. erase files.copied
  72. rem
  73. rem Copy wow64 binaries
  74. rem
  75. call :copywow64
  76. :justonefile
  77. rem
  78. rem first copy the hal that we require to the generic name
  79. rem
  80. echo Copying to target tree ...
  81. rem
  82. rem go through all of the files in the template file
  83. rem
  84. for /F %%F in (%_TEMPLATE_FILE%) do call :placefile %%~pF %%~nxF
  85. rem
  86. rem copy some boot files
  87. rem
  88. call :copyfile %SOURCE_2%\boot.ini %IMAGE_DRIVE%\ boot.ini
  89. call :copyfile %SOURCE_32%\ntldr %IMAGE_DRIVE%\ ntldr
  90. call :copyfile %SOURCE_32%\ntdetect.com %IMAGE_DRIVE%\ ntdetect.com
  91. call :copyfile %SOURCE_2%\autoexec.bat %IMAGE_DRIVE%\ autoexec.bat
  92. rem
  93. rem other misc files
  94. rem
  95. call :copyfile %SOURCE_1%\asms\1000\msft\windows\gdiplus\gdiplus.dll %IMAGE_DRIVE%\windows\system32 gdiplus.dll
  96. :makeimage
  97. rem
  98. rem make sure the syswow64 and other directories exist
  99. rem
  100. md %IMAGE_DRIVE%\windows\temp > NUL 2> NUL
  101. rem
  102. rem if copying just one file, skip the sxs stuff
  103. rem
  104. if NOT "%_TARGET_FILE%"=="" goto skipsxs
  105. rem
  106. rem Copy the sxs tree
  107. rem
  108. call :copysxs
  109. rem
  110. rem Also copy "documents and settings"
  111. rem
  112. call :copydocumentsandsettings
  113. rem
  114. rem now create the image
  115. rem
  116. :skipsxs
  117. echo check disk for %IMAGE_DRIVE%
  118. chkdsk %IMAGE_DRIVE%
  119. rem
  120. rem This is no longer needed as we are now using hives generated
  121. rem as a result of a 64-bit setup process
  122. rem
  123. rem echo %BINDIR%regprep %IMAGE_DRIVE%\windows\system32\config\system
  124. rem %BINDIR%regprep %IMAGE_DRIVE%\windows\system32\config\system
  125. if "%NO_IMAGE%"=="1" goto :eof
  126. echo create disk image %BINDIR%dskimage %IMAGE_DRIVE% %IMAGE_PATH%
  127. %BINDIR%dskimage %IMAGE_DRIVE% %IMAGE_PATH%
  128. goto :eof
  129. rem **********************************************************************
  130. rem
  131. rem Copy a file from the appropriate source to the appropriate
  132. rem destination
  133. rem
  134. rem %1 is the template path, sans file name
  135. rem %2 is the file name
  136. rem
  137. rem **********************************************************************
  138. :placefile
  139. set dest=%IMAGE_DRIVE%%1%2
  140. md %IMAGE_DRIVE%%1 > NUL 2> NUL
  141. rem
  142. rem first look in source_2 and copy if found
  143. rem
  144. set _src=%SOURCE_2%\%2
  145. if not exist %_src% goto placefile1
  146. call :copyfile %_src% %dest% %2
  147. goto :eof
  148. rem
  149. rem otherwise look in source_1 and copy if found
  150. rem
  151. :placefile1
  152. set _src=%SOURCE_1%\%2
  153. if not exist %_src% goto placefile_missing
  154. call :copyfile %_src% %dest% %2
  155. goto :eof
  156. rem
  157. rem the file could not be found, log it in files.missing
  158. rem
  159. :placefile_missing
  160. echo %dest% >> files.missing
  161. goto :eof
  162. rem **********************************************************************
  163. rem
  164. rem Copy one file.
  165. rem
  166. rem %1 is full path of source
  167. rem %2 is full path of destination
  168. rem %3 is the file name, used in compare if only copying one file
  169. rem
  170. rem **********************************************************************
  171. :copyfile
  172. if "%_TARGET_FILE%"=="" goto :copyit
  173. if "%_TARGET_FILE%"=="%3" goto :copyit
  174. goto :eof
  175. :copyit
  176. echo %1 - %2
  177. echo %1 - %2 >> files.copied
  178. copy %1 %2 > NUL
  179. goto :eof
  180. :copysxs
  181. rem
  182. rem This is temporarily disabled as this will break for a bit.
  183. rem JayKrell will notify us in a few days when it's safe to do
  184. rem this again (1/15/2002)
  185. rem
  186. rem call %BINDIR%\get_and_update_amd64_winsxs.bat
  187. rem
  188. rem Instead, perform the following two lines
  189. rem
  190. md %IMAGE_DRIVE%\windows\winsxs
  191. xcopy %BINDIR%\winsxs %IMAGE_DRIVE%\windows\winsxs /IERKYH
  192. goto :eof
  193. rem **********************************************************************
  194. rem
  195. rem Display usage
  196. rem
  197. rem **********************************************************************
  198. echo Missing one or more of the following variables:
  199. echo IMAGE_DRIVE
  200. echo IMAGE_PATH
  201. echo SOURCE_1
  202. echo
  203. goto :eof
  204. :copydocumentsandsettings
  205. rd /s /q "%IMAGE_DRIVE%\Documents and settings"
  206. xcopy /IS "%BINDIR%\Documents and settings" "%IMAGE_DRIVE%\Documents and settings" 1>NUL
  207. attrib +S +H "%IMAGE_DRIVE%\Documents and settings\desktop.ini" /s
  208. erase /s "%IMAGE_DRIVE%\Documents and settings\placeholder" /s 1>NUL
  209. goto :eof
  210. rem
  211. rem Copy Wow64 binaries
  212. rem
  213. :copywow64
  214. echo Copying Wow64 binaries...
  215. md %IMAGE_DRIVE%\windows\SysWow64 > NUL 2> NUL
  216. for %%a in (%SOURCE_WOW64%\*) do (
  217. set src=%%a
  218. set destname=%%~nxa
  219. set dest=!destname:~1!
  220. if /i not "!destname!" == "w!dest!" (
  221. set dest=!destname!
  222. )
  223. echo %IMAGE_DRIVE%\WINDOWS\SysWow64\!dest!
  224. copy !src! %IMAGE_DRIVE%\WINDOWS\SysWow64\!dest! /y > NUL
  225. )
  226. goto :eof