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.

413 lines
13 KiB

  1. REM
  2. REM Generate msrdpcli.msi from msrdpcl_.msi
  3. REM 1) create data.cab for client bins and stream that in
  4. REM 2) stream in custom.dll (custom action)
  5. REM 3) Update file table with new version and size info (for this build)
  6. REM 4) Update product and package code for this build (every build is like a 'new product')
  7. REM
  8. REM Assumes i386 build env (we don't build tsclient MSI for any other archs)
  9. REM Contact: nadima
  10. REM
  11. REM (need this switch for the BuildNum stuff below to work)
  12. setlocal ENABLEDELAYEDEXPANSION
  13. set MSIIDTDIR=%_NTPOSTBLD%\tsclient\win32\i386\idtdir
  14. set MSINAME=.\msrdpcli.msi
  15. REM make tempdirs
  16. if exist .\tmpcab (
  17. rmdir /q /s .\tmpcab
  18. if errorlevel 1 call errmsg.cmd "err deleting tmpcab dir"& goto errend
  19. )
  20. if exist %MSIIDTDIR% (
  21. rmdir /q /s %MSIIDTDIR%
  22. if errorlevel 1 call errmsg.cmd "err deleting idtdir dir"& goto errend
  23. )
  24. mkdir .\tmpcab
  25. if errorlevel 1 call errmsg.cmd "err creating .\tmpcab dir"& goto errend
  26. mkdir %MSIIDTDIR%
  27. if errorlevel 1 call errmsg.cmd "err creating %MSIIDTDIR% dir"& goto errend
  28. REM verify source files
  29. if not exist .\mstscax.dll (
  30. call errmsg.cmd "mstscax.dll is missing for tscmsigen.cmd"
  31. goto errend
  32. )
  33. if not exist .\mstsc.exe (
  34. call errmsg.cmd "mstsc.exe is missing for tscmsigen.cmd"
  35. goto errend
  36. )
  37. if not exist %_NTPOSTBLD%\mstscS.chm (
  38. call errmsg.cmd "mstscS.chm is missing for tscmsigen.cmd"
  39. goto errend
  40. )
  41. copy %_NTPOSTBLD%\mstscS.chm .\mstsc.chm
  42. if errorlevel 1 call errmsg.cmd "err copying up help (mstscS.chm) from binaries root"& goto errend
  43. if not exist .\msrdpcl_.msi (
  44. call errmsg.cmd "msrdpcl_.msi is missing for tscmsigen.cmd"
  45. goto errend
  46. )
  47. if not exist .\custom.dll (
  48. call errmsg.cmd "custom.dll is missing for tscmsigen.cmd"
  49. goto errend
  50. )
  51. if not exist .\wistream.vbs (
  52. call errmsg.cmd "wistream.vbs is missing for tscmsigen.cmd"
  53. goto errend
  54. )
  55. if not exist .\media.idt (
  56. call errmsg.cmd "media.idt is missing for tscmsigen.cmd"
  57. goto errend
  58. )
  59. REM rename files
  60. copy .\mstsc.exe .\tmpcab\F1060_mstsc.exe
  61. if errorlevel 1 call errmsg.cmd "err copying files to .\tmpcab"& goto errend
  62. copy .\mstsc.chm .\tmpcab\F1061_mstsc.chm
  63. if errorlevel 1 call errmsg.cmd "err copying files to .\tmpcab"& goto errend
  64. copy .\mstscax.dll .\tmpcab\F1059_mstscax.dll
  65. if errorlevel 1 call errmsg.cmd "err copying files to .\tmpcab"& goto errend
  66. REM now generate the cab file
  67. if exist .\data.cab (
  68. del data.cab
  69. )
  70. REM Sequence of files MUST match Sequence field of MSI File table (see Sequence property in File table)
  71. cabarc -s 6144 -m MSZIP -i 1 n .\data.cab .\tmpcab\F1060_mstsc.exe .\tmpcab\F1059_mstscax.dll .\tmpcab\F1061_mstsc.chm
  72. if errorlevel 1 (
  73. call errmsg.cmd "cabarc failed to generate .\data.cab"
  74. goto errend
  75. )
  76. rmdir /q /s .\tmpcab
  77. if errorlevel 1 call errmsg.cmd "err deleting tmpcab dir"& goto errend
  78. REM *****************************************************
  79. REM * Update the MSI *
  80. REM *****************************************************
  81. if exist %MSINAME% del %MSINAME%
  82. copy .\msrdpcl_.msi msrdpcli.msi
  83. if errorlevel 1 call errmsg.cmd "err copying msrdpcl_.msi to %MSINAME%" & goto errend
  84. REM *****************************************************
  85. REM * Stream in the client binaries (in cab form) *
  86. REM *****************************************************
  87. cscript.exe .\wistream.vbs %MSINAME% .\data.cab
  88. if errorlevel 1 (
  89. call errmsg.cmd "wistream failed to stream in .\data.cab"
  90. goto errend
  91. )
  92. REM *****************************************************
  93. REM * Stream in the update custom.dll *
  94. REM *****************************************************
  95. cscript.exe .\wistream.vbs %MSINAME% .\custom.dll Binary.New_Binary
  96. if errorlevel 1 (
  97. call errmsg.cmd "wistream failed to stream in .\custom.dll"
  98. goto errend
  99. )
  100. REM *****************************************************
  101. REM * Update the product version property *
  102. REM *****************************************************
  103. call :SetVersion %MSINAME% %MSIIDTDIR%
  104. REM *****************************************************
  105. REM * Give every package that gets generated, a new *
  106. REM * product and package code. MSI will always thing *
  107. REM * its upgrading. *
  108. REM *****************************************************
  109. call :UpdateProductCode %MSINAME% %MSIIDTDIR%
  110. call :UpdatePackageCode %MSINAME% %MSIIDTDIR%
  111. call :SetUpgradeCode %MSINAME% %MSIIDTDIR%
  112. REM *****************************************************
  113. REM * Update the filetable with file size and ver info *
  114. REM * assumes the source files are in the same directory*
  115. REM *****************************************************
  116. call cscript.exe .\\wifilver.vbs /U %MSINAME%
  117. if errorlevel 1 (
  118. call errmsg.cmd "wifilver failed"
  119. goto errend
  120. )
  121. REM *****************************************************
  122. REM * Update the media table to reflect that the data.cab
  123. REM * is a streamed in archive *
  124. REM *****************************************************
  125. copy .\media.idt %MSIIDTDIR%\media.idt
  126. if errorlevel 1 call errmsg.cmd "err copying media.idt files to IDTDIR"& goto errend
  127. call cscript.exe .\wiimport.vbs %MSINAME% %MSIIDTDIR% media.idt
  128. if errorlevel 1 (
  129. call errmsg.cmd "Import update media table failed"
  130. goto errend
  131. )
  132. REM *****************************************************
  133. REM * Patch the Control table to fix dev src lock problems
  134. REM *****************************************************
  135. msiquery.exe "UPDATE Control Set Attributes = 3 WHERE Type = 'RadioButtonGroup'" %MSINAME%
  136. call logmsg.cmd "tscmsigen.cmd COMPLETED OK!"
  137. REM we're done
  138. endlocal
  139. goto end
  140. REM ******************SUBS START HERE********************
  141. REM *****************************************************
  142. REM * Update version sub *
  143. REM * (updates version in the property table *
  144. REM *****************************************************
  145. :SetVersion
  146. REM
  147. REM Update the version in the Property table
  148. REM and update the version in the Upgrade Table
  149. REM
  150. REM %1 is the msi file
  151. REM %2 is the msiidt directory
  152. set ntverp=%_NTBINDIR%\public\sdk\inc\ntverp.h
  153. if NOT EXIST %ntverp% (echo Can't find ntverp.h.&goto :ErrEnd)
  154. for /f "tokens=3 delims=, " %%i in ('findstr /c:"#define VER_PRODUCTMAJORVERSION " %ntverp%') do (
  155. set /a ProductMajor="%%i"
  156. set BuildNum=%%i
  157. )
  158. for /f "tokens=3 delims=, " %%i in ('findstr /c:"#define VER_PRODUCTMINORVERSION " %ntverp%') do (
  159. set /a ProductMinor="%%i"
  160. set BuildNum=!BuildNum!.%%i
  161. )
  162. for /f "tokens=6" %%i in ('findstr /c:"#define VER_PRODUCTBUILD " %ntverp%') do (
  163. set /a ProductBuild="%%i"
  164. set BuildNum=!BuildNum!.%%i
  165. )
  166. for /f "tokens=3" %%i in ('findstr /c:"#define VER_PRODUCTBUILD_QFE " %ntverp%') do (
  167. set /a ProductQfe="%%i"
  168. set BuildNum=!BuildNum!.%%i
  169. )
  170. call logmsg.cmd "Updating the msrdpcli.msi ProductVersion to !BuildNum! in prop table"
  171. call cscript.exe .\\wiexport.vbs %1 %2 Property
  172. copy %2\Property.idt %2\Property.idt.old > nul
  173. del /f %2\Property.idt
  174. for /f "tokens=1,2,* delims= " %%a in (%2\Property.idt.old) do (
  175. if /i "%%a" == "ProductVersion" (
  176. echo %%a !BuildNum!>>%2\Property.idt
  177. ) else (
  178. if /i "%%a" == "ProductLanguage" (
  179. set Language=%%b
  180. )
  181. if "%%c"=="" (
  182. echo %%a %%b>>%2\Property.idt
  183. ) else (
  184. echo %%a %%b %%c>>%2\Property.idt
  185. )
  186. )
  187. )
  188. REM Set the property that says if this is an x86 or a 64-bit package
  189. if /i "%CurArch%" == "i386" (
  190. echo Install32 ^1>>%2\Property.idt
  191. )
  192. if /i "%CurArch%" == "ia64" (
  193. echo Install64 ^1>>%2\Property.idt
  194. )
  195. call cscript.exe .\\wiimport.vbs //nologo %1 %2 Property.idt
  196. if errorlevel 1 (
  197. call errmsg.cmd "Import of Property table in SetVersion back into msrdpcli.msi failed!"
  198. goto errend
  199. )
  200. REM call logmsg.cmd "Finished updating the ProductVersion in the property table"
  201. goto :EOF
  202. REM *****************************************************
  203. REM * Update product code sub *
  204. REM *****************************************************
  205. :UpdateProductCode
  206. REM Update the product code GUID in the property table
  207. REM
  208. REM %1 is the msi file
  209. REM %2 is the msi idt directory
  210. call logmsg.cmd "Updating the product code GUID in the property table"
  211. call cscript.exe .\\wiexport.vbs %1 %2 Property
  212. copy %2\Property.idt %2\Property.idt.old > nul
  213. del /f %2\Property.idt
  214. uuidgen.exe -c -o%2\productguid
  215. for /f "tokens=1" %%a in (%2\productguid) do (
  216. set NewGuid=%%a
  217. )
  218. call logmsg.cmd "ProductCode GUID = !NewGuid!"
  219. for /f "tokens=1,2,* delims= " %%a in (%2\Property.idt.old) do (
  220. if /i "%%a" == "ProductCode" (
  221. echo %%a {%NewGuid%}>>%2\Property.idt
  222. ) else (
  223. if "%%c"=="" (
  224. echo %%a %%b>>%2\Property.idt
  225. ) else (
  226. echo %%a %%b %%c>>%2\Property.idt
  227. )
  228. )
  229. )
  230. call cscript.exe .\wiimport.vbs //nologo %1 %2 Property.idt
  231. if errorlevel 1 (
  232. call errmsg.cmd "Import of Property table in UpdateProductCode back into msrdpcli.msi failed!"
  233. goto errend
  234. )
  235. call logmsg.cmd "Finished updating the product code GUID in the property table"
  236. goto :EOF
  237. REM *****************************************************
  238. REM * Update package code sub *
  239. REM *****************************************************
  240. :UpdatePackageCode
  241. REM
  242. REM Update the guid for the package code in the _SummaryInformation table
  243. REM %1 is the msi file
  244. REM %2 is the msiidt directory
  245. call logmsg.cmd "Updating the package code GUID in the _SummaryInformation table"
  246. call cscript.exe .\\wiexport.vbs //nologo %1 %2 _SummaryInformation
  247. copy %2\_SummaryInformation.idt %2\_SummaryInformation.idt.old > nul
  248. del /f %2\_SummaryInformation.idt
  249. uuidgen.exe -c -o%2\packageguid
  250. for /f "tokens=1" %%a in (%2\packageguid) do (
  251. set NewGuid=%%a
  252. )
  253. call logmsg.cmd "ProductCode GUID (package code) = !NewGuid!"
  254. for /f "tokens=1,2 delims= " %%a in (%2\_SummaryInformation.idt.old) do (
  255. if "%%a" == "9" (
  256. echo %%a {%NewGuid%}>>%2\_SummaryInformation.idt
  257. ) else (
  258. echo %%a %%b>>%2\_SummaryInformation.idt
  259. )
  260. )
  261. call cscript.exe .\\wiimport.vbs //nologo %1 %2 _SummaryInformation.idt
  262. goto :EOF
  263. REM *****************************************************
  264. REM * Set upgrade code to ease future upgrades *
  265. REM *****************************************************
  266. :SetUpgradeCode
  267. REM Update the upgrade code GUID in the property table
  268. REM
  269. REM %1 is the msi file
  270. REM %2 is the msi idt directory
  271. call logmsg.cmd "Setting the upgrade code GUID in the property table"
  272. call cscript.exe .\\wiexport.vbs //nologo %1 %2 Property
  273. copy %2\Property.idt %2\Property.idt.old > nul
  274. del /f %2\Property.idt
  275. set CurUpgradeGUID=17258378-2B69-4900-9754-1CAD4D0FB7CC
  276. call logmsg.cmd "!CurArch! Upgrade Code GUID = !CurUpgradeGUID!"
  277. for /f "tokens=1,2,* delims= " %%a in (%2\Property.idt.old) do (
  278. if /i "%%a" == "UpgradeCode" (
  279. echo %%a {!CurUpgradeGuid!}>>%2\Property.idt
  280. ) else (
  281. if "%%c"=="" (
  282. echo %%a %%b>>%2\Property.idt
  283. ) else (
  284. echo %%a %%b %%c>>%2\Property.idt
  285. )
  286. )
  287. )
  288. call cscript.exe .\\wiimport.vbs //nologo %1 %2 Property.idt
  289. if errorlevel 1 (
  290. call errmsg.cmd "Import of Property table in SetUpgradeCode back into msrdpcli.msi failed!"
  291. goto errend
  292. )
  293. call logmsg.cmd "Finished updating the product code GUID in the property table"
  294. REM Update the upgrade code GUID in the Upgrade table
  295. call logmsg.cmd "Updating the upgrade code in the Upgrade table
  296. call cscript.exe .\\wiexport.vbs //nologo %1 %2 Upgrade
  297. copy %2\Upgrade.idt %2\Upgrade.idt.old > nul
  298. del /f %2\Upgrade.idt
  299. REM
  300. REM Put the header to the file
  301. REM Echo the first three lines to the file
  302. set /a count=1
  303. for /f "tokens=*" %%a in (%2\upgrade.idt.old) do (
  304. if !count! LEQ 3 echo %%a>>%2\Upgrade.idt
  305. set /a count=!count!+1
  306. )
  307. set VersionMin=5.1.2600.0
  308. REM The Language variable was obtained from the Property table in :SetVersion.
  309. echo {!CurUpgradeGuid!} !VersionMin! !BuildNum! !Language! 256 OLDAPPFOUND>>%2\Upgrade.idt
  310. call cscript.exe .\\wiimport.vbs //nologo %1 %2 Upgrade.idt
  311. call logmsg.cmd "Finished updating the Upgrade code in the upgrade table"
  312. REM Now set up registry keys for Windows Update to make sure we can be upgraded
  313. call cscript.exe .\\wiexport.vbs //nologo %1 %2 Registry
  314. echo Registry32 2 SOFTWARE\Microsoft\Terminal Server Client\Installed Components IsInstalled #1 Global_Default_Registry_Keys>>%2\Registry.idt
  315. echo Registry33 2 SOFTWARE\Microsoft\Terminal Server Client\Installed Components Version !ProductMajor!,!ProductMinor!,!ProductBuild!,!ProductQfe! Global_Default_Registry_Keys>>%2\Registry.idt
  316. call cscript.exe .\\wiimport.vbs //nologo %1 %2 Registry.idt
  317. call logmsg.cmd "Finished updating the Registry code in the registry table"
  318. goto :EOF
  319. :errend
  320. goto :EOF
  321. :end
  322. seterror.exe 0
  323. goto :EOF